Returns parsed response.

@param string $rawResponse
@param array $infoList
@param WebDriver_Command $command
@throws WebDriver_Exception
@throws WebDriver_NoSeleniumException
@return array
770277
protected function parseResponse($rawResponse, $infoList, $command)
    {
        $httpStatusCode = isset($infoList['http_code']) ? $infoList['http_code'] : 0;
        $messageList = [
            "HTTP Response Status Code: {$httpStatusCode}",
            WebDriver_Exception_Protocol::getCommandDescription($command)
        ];
        switch ($httpStatusCode) {
            case 0:
                $message = $this->buildResponseErrorMessage("No response or broken.", $messageList);
                throw new WebDriver_NoSeleniumException($message);
            case WebDriver_Http::SUCCESS_OK:
                $decodedJsonList = json_decode($rawResponse, true);
                if ($decodedJsonList === null) {
                    $errorList = ["Can't decode response JSON:", json_last_error_msg()];
                    $message = $this->buildResponseErrorMessage($errorList, $messageList);
                    throw new WebDriver_Exception_Protocol($message);
                }
                if (isset($decodedJsonList['status']) &&
                    !WebDriver_Exception_FailedCommand::isOk($decodedJsonList['status'])) {
                    throw WebDriver_Exception_FailedCommand::factory(
                        $command,
                        $infoList,
                        $rawResponse,
                        $decodedJsonList
                    );
                }
                return $decodedJsonList;
            default:
                if (WebDriver_Http::isError($httpStatusCode)) {
                    throw WebDriver_Exception_Protocol::factory($command, $infoList, $rawResponse);
                }
                $errorMessage = "Unexpected HTTP status code: {$httpStatusCode}";
                $message = $this->buildResponseErrorMessage($errorMessage, $messageList);
                throw new WebDriver_Exception($message);
        }
    }
184893
protected function displayHelpForCommand(Collection $handlers, string $command): Response
    {
        $helpRequest = clone $this->request;

        $helpRequest->text = $command;

        /** @var \Spatie\SlashCommand\Handlers $handler */
        $handler = $handlers->filter(function (HandlesSlashCommand $handler) use ($helpRequest) {
            return $handler->canHandle($helpRequest);
        })
            ->first();

        $field = AttachmentField::create($handler->getFullCommand(), $handler->getHelpDescription());

        return $this->respondToSlack('')
            ->withAttachment(
                Attachment::create()->addField($field)
            );
    }
1030211
protected function createResponse($rawResponse)
    {
        $response = new Response();

        $headerSize = curl_getinfo($this->handle, CURLINFO_HEADER_SIZE);
        $rawHeaders = trim(substr($rawResponse, 0, $headerSize));
        $rawHeadersArray = explode("\r\n\r\n", $rawHeaders);

        if (!empty($rawHeadersArray)) {
            $headerLines = explode("\r\n", $rawHeadersArray[0]);
            foreach ($headerLines as $headerLine) {
                if (stripos(trim($headerLine), 'http', 0) === 0) {
                    if (preg_match('/^http\/((\d*[.])?\d+)\s+(\d+)\s+([a-z]+)/i', trim($headerLine), $matches)) {
                        $response = $response->withStatus($matches[3], $matches[4])
                            ->withProtocolVersion($matches[1]);
                    }
                    continue;
                }

                $header = explode(':', $headerLine, 2);
                $name = trim($header[0]);
                $value = trim($header[1]);

                if ($response->hasHeader($name)) {
                    $response = $response->withAddedHeader($name, $value);
                } else {
                    $response = $response->withHeader($name, $value);
                }
            }
        }

        $content = substr($rawResponse, $headerSize);
        $response->getBody()->write($content);
        $response->getBody()->rewind();

        return $response;
    }
820248
public static PowerShellResponse executeSingleCommand(String command) {
        PowerShellResponse response = null;

        try (PowerShell session = PowerShell.openSession()) {
            response = session.executeCommand(command);
        } catch (PowerShellNotAvailableException ex) {
            logger.log(Level.SEVERE, "PowerShell not available", ex);
        }

        return response;
    }
674816
private function parseResponse($rawResponse, $headerSize)
    {
        foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) {
            if (stripos($rawResponse, $established_header) !== false) {
                $rawResponse = str_ireplace($established_header, '', $rawResponse);
                // Older cURL versions did not account for proxy headers in the
                // header size
                if (!$this->needsCurlProxyFix()) {
                    $headerSize -= strlen($established_header);
                }
                break;
            }
        }

        $responseBody = substr($rawResponse, $headerSize);

        return $responseBody;
    }
658650
public static function factory(WebDriver_Command $command, array $infoList = [], $rawResponse = null)
    {
        $httpStatusCode = isset($infoList['http_code']) ? $infoList['http_code'] : 0;
        switch ($httpStatusCode) {
            case WebDriver_Http::CLIENT_ERROR_NOT_FOUND:
            case WebDriver_Http::SERVER_ERROR_NOT_IMPLEMENTED:
            case WebDriver_Http::CLIENT_ERROR_METHOD_NOT_ALLOWED:
            case WebDriver_Http::CLIENT_ERROR_BAD_REQUEST:
                return WebDriver_Exception_InvalidRequest::factory($command, $infoList, $rawResponse);
            case WebDriver_Http::SERVER_ERROR_INTERNAL:
                $decodedJsonList = json_decode($rawResponse, true);
                $messageList = ["Internal Server Error"];
                if ($decodedJsonList === null) {
                    $messageList[] = "Cant decode response JSON:";
                    $messageList[] = json_last_error_msg();
                    $messageList[] = $rawResponse;
                    $exception = new WebDriver_Exception_Protocol(implode("\n", $messageList));
                    $exception->httpStatusCode = $httpStatusCode;
                    return $exception;
                }
                $exception = WebDriver_Exception_FailedCommand::factory(
                    $command,
                    $infoList,
                    $rawResponse,
                    $decodedJsonList
                );
                $exception->httpStatusCode = $httpStatusCode;
                return $exception;
            default:
                $messageList = [
                    "Unknown error: {$httpStatusCode}",
                    $rawResponse,
                    static::getCommandDescription($command)
                ];
                $exception = new WebDriver_Exception_Protocol(implode("\n", $messageList));
                $exception->httpStatusCode = $httpStatusCode;
                return $exception;
        }
    }
1159864
public function post($command, $params = null, $postcontenttype = 'application/json')
    {
        $url = $command;

        $headers = array('Content-Type' => $postcontenttype);

        $content = $params;
        if ($postcontenttype == 'application/json') {
            $content = json_encode($params);
        }

        try {
            $response = $this->client->post($url, ['headers' => $headers, 'body' => $content]);
        } catch (\Exception $e) {
            return null;
        }
        $this->checkError($response, $url);

        return $response->getBody();
    }
1094430
private function calculateParameters(CommandInterface $command, $serializedModelId)
    {
        $parameters = (array) $command->getParameters();
        if ($command instanceof ToggleCommandInterface) {
            // Toggle has to trigger the javascript.
            $parameters['act'] = $command->getName();
            $parameters['id']  = $serializedModelId;

            return $parameters;
        }
        if (($command instanceof CutCommandInterface) || ($command instanceof CopyCommandInterface)) {
            // Cut & copy need some special information.
            $parameters        = [];
            $parameters['act'] = $command->getName();

            $inputProvider = $this->environment->getInputProvider();
            // If we have a pid add it, used for mode 4 and all parent -> current views.
            if ($inputProvider->hasParameter('pid')) {
                $parameters['pid'] = $inputProvider->getParameter('pid');
            }

            // Source is the id of the element which should move.
            $parameters['source'] = $serializedModelId;

            return $parameters;
        }

        $extra = (array) $command->getExtra();

        $parameters[($extra['idparam'] ?? null) ?: 'id'] = $serializedModelId;

        return $parameters;
    }
569172
public function rawResponseToArray($responseRaw, $format)
    {
        if (strstr($responseRaw, 'winstrom')) {
            $nsbackup        = $this->nameSpace;
            $this->nameSpace = 'winstrom';
            $response        = parent::rawResponseToArray($responseRaw, $format);
            $this->nameSpace = $nsbackup;
        } else {
            $response = parent::rawResponseToArray($responseRaw, $format);
        }
        return $response;
    }
588217
protected function _parseResponse()
    {
        /**
         * According to the HTTP spec, we have to respect \n\n too
         *  @todo: Respect \n\n
         */
        $break_1 = strpos($this->_rawResponse, "\r\n\r\n");
        $break_2 = strpos($this->_rawResponse, "\n\n");
        $break   = 0;

        if    ($break_1 && $break_2 === FALSE) $break = $break_1;
        elseif($break_2 && $break_1 === FALSE) $break = $break_2;
        elseif($break_1 < $break_2) $break = $break_1;
        else $break = $break_2;

        # Let's check to see if we recieved a header but no body
        if($break === FALSE)
        {
            if(strpos($this->_rawResponse, 'HTTP/') !== FALSE)
            {
                $break = strlen($this->_rawResponse);
            }
            else
            {
                throw new Exception("A valid response was not received from the host");
            }
        }

        $header = substr($this->_rawResponse, 0, $break);
        $this->_responseHeaders = $this->_parseResponseHeaders($header);
        $this->_responseBody    = substr($this->_rawResponse, $break + 3);
    }
520665
private function convertResponseToResult(
        $category,
        array $description,
        ResponseInterface $response,
        CommandInterface $command
    ) {
        if ($response->getStatusCode() >= 400) {
            throw new \Exception($response->getBody()->__toString(), $response->getStatusCode());
        }

        $operation = $description['operations'][$category][$command->getName()];
        if (!isset($operation['responseTypes']) || count($operation['responseTypes']) === 0) {
            try {
                $content = $response->getBody()->__toString();
                if (empty($content)) {
                    $content = '{}';
                }

                return new Result(json_decode($content, true));
            } catch (\Exception $e) {
                dump($response->getBody()->__toString());

                throw $e;
            }
        }

        // attempt to deserialize into JSON only if there is a content in the response
        $data = null;
        if ($response->getStatusCode() !== 204) {
            $data = json_decode($response->getBody()->__toString());
        }

        list($responseType, $array) = $this->getResponseType($command->getName(), $operation);

        $firstType = explode('/', $this->dashesToCamelCase($responseType, true));
        $class     = $this->mapBadDocs(
            sprintf(
                '\\RestCord\\Model\\%s\\%s',
                ucwords($firstType[0]),
                ucwords($firstType[1])
            )
        );

        if (!class_exists($class)) {
            return new Result($data);
        }
        if ($data === null) {
            return new Result([]);
        }

        $mapper                   = new \JsonMapper();
        $mapper->bStrictNullTypes = false;

        if ($array) {
            return array_map(
                function ($item) use ($class, $mapper) {
                    return $mapper->map($item, new $class());
                },
                $data
            );
        }

        return $mapper->map($data, new $class());
    }
1266098
public function executeCommand($command, array $parameters = array())
    {
        $content = $this->post(
            sprintf('http://%s:%d/_s_/dyn/Driver_%s', $this->host, $this->port, $command),
            array_merge($parameters, array('sahisid' => $this->sid))
        )->getContent();

        if (false !== strpos($content, 'SAHI_ERROR')) {
            throw new Exception\ConnectionException('Sahi proxy error. Full response:' . PHP_EOL . $content);
        }

        return $content;
    }
202165
protected function parseFromString( $raw_handler, $default_method, $namespace ) {
		list( $class, $method ) = array_pad( preg_split( '/@|::/', $raw_handler, 2 ), 2, '' );

		if ( empty( $method ) ) {
			$method = $default_method;
		}

		if ( ! empty( $class ) && ! empty( $method ) ) {
			return [
				'class' => $class,
				'method' => $method,
				'namespace' => $namespace,
			];
		}

		return null;
	}
1153365
def _handle_response(response, command, id_xpath='./id', **kwargs):
    
    _response_switch = {
        'insert': ModifyResponse,
        'replace': ModifyResponse,
        'partial-replace': ModifyResponse,
        'update': ModifyResponse,
        'delete': ModifyResponse,
        'search-delete': SearchDeleteResponse,
        'reindex': Response,
        'backup': Response,
        'restore': Response,
        'clear': Response,
        'status': StatusResponse,
        'search': SearchResponse,
        'retrieve': ListResponse,
        'similar': ListResponse,
        'lookup': LookupResponse,
        'alternatives': AlternativesResponse,
        'list-words': WordsResponse,
        'list-first': ListResponse,
        'list-last': ListResponse,
        'retrieve-last': ListResponse,
        'retrieve-first': ListResponse,
        'show-history': None,
        'list-paths': ListPathsResponse,
        'list-facets': ListFacetsResponse}
    try:
        request_class = _response_switch[command]
    except KeyError:
        request_class = Response
    return request_class(response, id_xpath, **kwargs)
1024358
protected function parse( $raw_handler, $default_method, $namespace ) {
		if ( $raw_handler instanceof Closure ) {
			return $raw_handler;
		}

		return $this->parseFromString( $raw_handler, $default_method, $namespace );
	}
374994
protected function parseCommand($command, $parameters)
    {
        if (is_subclass_of($command, SymfonyCommand::class)) {
            $callingClass = true;

            $command = $this->laravel->make($command)->getName();
        }

        if (! isset($callingClass) && empty($parameters)) {
            $command = $this->getCommandName($input = new StringInput($command));
        } else {
            array_unshift($parameters, $command);

            $input = new ArrayInput($parameters);
        }

        return [$command, $input ?? null];
    }
1042761
public function visit(
        CommandInterface $command,
        RequestInterface $request,
        Parameter $param
    ) {
        $uri = $request->getUri();
        $query = Psr7\parse_query($uri->getQuery());

        $query[$param->getWireName()] = $this->prepareValue(
            $command[$param->getName()],
            $param
        );

        $uri = $uri->withQuery($this->querySerializer->aggregate($query));

        return $request->withUri($uri);
    }