{@inheritDoc}

@return array
@throws HTTPResponse_Exception
341782
public function check()
    {
        $response = Director::test($this->url);

        if ($response->getStatusCode() != 200) {
            return [
                EnvironmentCheck::ERROR,
                sprintf('Error retrieving "%s" (Code: %d)', $this->url, $response->getStatusCode())
            ];
        } elseif ($this->testString && (strpos($response->getBody(), $this->testString) === false)) {
            return [
                EnvironmentCheck::WARNING,
                sprintf('Success retrieving "%s", but string "%s" not found', $this->url, $this->testString)
            ];
        }
        return [
            EnvironmentCheck::OK,
            sprintf('Success retrieving "%s"', $this->url)
        ];
    }
57378
public function getTokens(): array
    {
        $response = $this
            ->httpClient
            ->get(
                sprintf(
                    '/%s/tokens',
                    $this->getAppUUID()->getId()
                ),
                'get',
                [],
                [],
                Http::getApisearchHeaders($this)
            );

        self::throwTransportableExceptionIfNeeded($response);

        return array_map(function (array $token) {
            return Token::createFromArray($token);
        }, $response['body']);
    }
1311731
public function jsonSerialize(): array
    {
        $instruction = ['type' => $this->type];

        if ($this->type !== self::TYPE_NOOP) {
            $instruction = array_merge($instruction, [
                'name' => $this->name,
                'catched' => $this->shouldCatchErrors,
            ]);

            if ($this->type !== self::TYPE_GET) {
                $instruction['value'] = $this->value;
            }

            if ($this->resource !== null) {
                $instruction['resource'] = $this->resource;
            }
        }

        return $instruction;
    }
253260
public function getResponses(): array
    {
        $responses = [];

        foreach ($this->responses as $request) {
            $responses[] = $this->responses[$request];
        }

        return $responses;
    }
833590
public function getResponseData(): Response
    {
        $connectionResponse = new ConnectionResponseImpl();
        $errorResponse = $this->streamSocket->read();
        if ($errorResponse !== null) {
            $this->getLogger()->error('Send error: ' . $errorResponse);
            $this->streamSocket->disconnect();
            $response = @unpack('Ccommand/Cstatus/Nidentifier', $errorResponse);
            if (!empty($response)) {
                $connectionResponse->setErrorResponse($response);
            } else {
                $connectionResponse->setErrorResponse(null);
            }
        }

        return $connectionResponse;
    }
1297343
public function send()
    {
        $response = $this->sendApiCall(self::ACTION_CREATE, $this->getCreateUrl());

        if (!isset($response->getBody()['_embedded']['items'])) {
            throw new Exception('Invalid response returned from server', Exception::INVALID_RESPONSE);
        }

        $result = array();
        foreach ($response->getBody()['_embedded']['items'] as $item) {
            $result[] = $sms = new NumberLookup($this->client, $this->factory);
            $sms->setFields($item);
        }

        return $result;
    }
1211167
public function jsonSerialize() : array
    {
        return [
            'id'        => $this->getId(),
            'timestamp' => $this->getTimestamp(),
            'context'   => $this->getContext(),
            'culprit'   => sprintf('%s:%d', $this->throwable->getFile(), $this->throwable->getLine()),
            'exception' => [
                'message'    => $this->throwable->getMessage(),
                'type'       => get_class($this->throwable),
                'code'       => $this->throwable->getCode(),
                'stacktrace' => $this->mapStacktrace(),
            ],
            'processor' => [
                'event' => 'error',
                'name'  => 'error',
            ]
        ];
    }
879359
protected function executeRequest()
    {
        // @todo encode response add to array, pass to response

        $result = array();

        foreach ($this->request->getClassifiers() as $classifierString) {
            $classifier = explode('/', $classifierString);

            if (! $this->classifierExists($classifierString)) {
                throw new Exception\ServiceReaderException("Classifier {$classifierString} does not exist");
            }

            $queryURL = sprintf(
                $this->apiQueryStringRequestFormat,
                $this->apiEndpoint,
                rawurlencode($classifier[0]),
                rawurlencode($classifier[1]),
                urlencode($this->apiKey),
                urlencode($this->request->getTextData()),
                $this->apiVersion,
                strtolower($this->request->getResponseFormat()) !== 'xml' ?
                "&output={$this->request->getResponseFormat()}" : null
            );

            if (!is_callable('curl_init')) {
                throw new Exception\ServiceReaderException('cURL not found.');
            }

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_URL, $queryURL);
            $response = curl_exec($ch);
            curl_close($ch);

            if (strpos($response, "<Exception>") !== false) {
                preg_match("/<Exception\>(.*)<\/Exception>/mu", $response, $matches);
                throw new Exception\ServiceReaderException($matches[1]);
            }

            $result[$classifier[1]] = $response;
        }
        return new UclassifyResponse($result, $this->request);
    }
488575
public function getJsonResponse()
    {
        $json = json_decode($this->httpResponse);
        if (is_null($json) && json_last_error() != JSON_ERROR_NONE) {
            return null; // decode error
        } else {
            return is_object($json) ? $json : null;
        }
    }
668767
private function extractHeadersFromResponse() {
    $response = "";
    $code = $this->response->getStatusCode();
    $text = HttpUtil::getResponseTextForCode($code);
    $response .= sprintf(self::STATUS_LINE_FORMAT, $code, $text);

    foreach($this->response->getHeaderList() as $header) {
      $response .= sprintf("%s: %s%s",
                           $header->getKey(),
                           $header->getValue(),
                           self::CRLF);
    }
    $response .= self::CRLF;
    return $response;
  }
501223
public function getResult()
  {
    // HTTP 204
    if (Response::HTTP_NO_CONTENT == $this->getResponse()
        ->getStatusCode()) {
      return [];
    }

    // Get content
    $contents = $this->getResponse()
      ->getBody()
      ->getContents();
    if (empty($contents)) {
      throw new ResponseDecodeException(
        'Body contents is empty with HTTP code '.$this->getResponse()
          ->getStatusCode()
      );
    }

    // Decode to JSON
    $items = json_decode($contents, true);
    if (JSON_ERROR_NONE != json_last_error()) {
      throw new ResponseDecodeException('JSON error: '.json_last_error_msg());
    }

    return $items;
  }
1080705
public function validated(): array
    {
        $config = $this->container->make('katsana.manager')->config('webhook');

        $signature = new Signature($config['signature']);
        $header = $this->header('X_SIGNATURE') ?? '';

        if (! $signature->verify($header, $this->getContent(), ($config['threshold'] ?? 3600))) {
            throw new HttpException(419, 'Unable to verify X-Signature.');
        }

        return $this->post();
    }
153394
public function getData(): array
    {
        return [
            $this->serverOriginScheme,
            $this->serverOriginHost,
            $this->serverOriginPort,
            $this->isPreFlightCanBeCached,
            $this->preFlightCacheMaxAge,
            $this->isForceAddMethods,
            $this->isForceAddHeaders,
            $this->isUseCredentials,
            $this->areAllOriginsAllowed,
            $this->allowedOrigins,
            $this->areAllMethodsAllowed,
            $this->allowedLcMethods,
            $this->allowedMethodsList,
            $this->areAllHeadersAllowed,
            $this->allowedLcHeaders,
            $this->allowedHeadersList,
            $this->exposedHeadersList,
            $this->isCheckHost,
        ];
    }
291680
public function getResponseHeaders() {
        $requestHeaders = [];

        if ($this->headers instanceof \ArrayAccess) {
            while ($this->headers->valid()) {
                $requestHeaders[$this->headers->key()] = $this->headers->current();
                $this->headers->next();
            }
        }

        return $requestHeaders;
    }
1313838
public function getHttpMethodOmissionsAsArray()
    {

        // initialize the array for the HTTP method omissions
        $httpMethodOmissions = array();

        // prepare the HTTP method omissions
        /** @var \AppserverIo\Appserver\Core\Api\Node\HttpMethodOmissionNode $httpMethodOmissionNode */
        foreach ($this->getHttpMethodOmissions() as $httpMethodOmissionNode) {
            $httpMethodOmissions[] = strtoupper($httpMethodOmissionNode->__toString());
        }

        // return the array with the HTTP method omissions
        return $httpMethodOmissions;
    }
1201047
public function response(): array
    {
        if ($this->responseEvent instanceof ReturnedEvent) {
            return [null, $this->responseEvent->value()];
        }

        if ($this->responseEvent instanceof ThrewEvent) {
            return [$this->responseEvent->exception(), null];
        }

        throw new UndefinedResponseException('The call has not yet responded.');
    }
514101
public function jsonArray()
    {

        if (!$this->isContentType('application/json')) {
            throw new Exception('Response is not JSON');
        }

        if (empty($this->_jsonAsArray)) {
            $this->_jsonAsArray = Utils::json_parse($this->text(), true);
        }

        return $this->_jsonAsArray;

    }