Sending deffered request.
@return array
@throws InvalidCallException
183962
private function doSend()
    {
        try {
            if (!empty($this->sentContentIds) && count($this->sentContentIds) > $this->batchLimit) {
                throw new InvalidCallException(sprintf("Request limit reached! Max %d requests per batch is accepted!", $this->batchLimit));
            }
            $response = $this->request->send();
            $this->request = null;
            if ($response instanceof ApiResponse) {
                $response = [$response];
            }
            $responses = [];
            $index = 0;
            foreach ($response as $_response) {
                $responses[$_response->id ?? $index] = $this->handleResponse($_response);
                $index++;
            }
            foreach ($this->sentContentIds as $sentContentId) {
                if (!array_key_exists($sentContentId, $responses)) {
                    $responses[$sentContentId] = new ApiResponse([
                        'success' => false,
                        'error' => new ResponseError([
                            'type' => BadGatewayHttpException::class,
                            'code' => ResponseError::ERRORCODE_HTTP_RESPONSE_ERROR,
                            'message' => ['httpError' => 'Sent content not found in response!'],
                        ]),
                    ]);
                }
            }
            return $responses;
        } finally {
            $this->sentContentIds = [];
        }
    }
599670
public function sendHeaders()
     {
         $response = $this->getResponse();
         $headers = $response->getHeaders();
         $isAjax = $response->getRequest()->isAjax();

         if (isset($headers['Location']) && $response->isSuccess() && !$isAjax) {
             $response->setStatus(AnHttpResponse::SEE_OTHER);
         }

         return parent::sendHeaders();
     }
12709
public function send()
    {
        $allowed_status_codes = array_merge(array(200), $this->ignoredStatusCodes);
        $this->ignoredStatusCodes = array();

        try {
            $this->_setupCurl();
            $response = curl_exec($this->curl);

            if (!in_array(curl_getinfo($this->curl, CURLINFO_HTTP_CODE), $allowed_status_codes)) {
                if (curl_errno($this->curl)) {
                    throw new \RuntimeException('The HTTP request failed: ' . curl_error($this->curl));
                }
                throw new \RuntimeException('The HTTP request failed: unknown error.');
            }
            curl_close($this->curl);

            return $this->hasToDecodeResponse ? json_decode($response) : $response;
        } catch (Exception $e) {  }
    }
1373461
public function sendRequest()
    {
        if ($this->error->hasError() || !$this->http) {
            return;
        }

        if (class_exists($this->dispatcher)) {
            $dispatcherClass = $this->dispatcher;
            $dispatcher = new $dispatcherClass($this->instance->getQuery());
            if ($dispatcher instanceof AbstractDispatcher) {
                $payload = array(
                    'data' => json_encode(array(
                        'config' => $this->config->getRawConfig(),
                        'sql' => $this->instance->getQuery()->toString(),
                        'limit' => $this->instance->getQuery()->getLimit(),
                        'offset' => $this->instance->getQuery()->getOffset(),
                        'single' => $this->instance->getQuery()->isSingle(),
                    )),
                    'key' => $this->key,
                    'method' => $this->method,
                );
                $jsonResult = '[]';

                try {
                    // Guzzle Old
                    if (get_class($this->http) == 'Guzzle\Http\Client') {
                        $request = $this->http->post($this->url, array(), $payload);
                        $response = $request->send();
                        $jsonResult = $response->getBody(true);
                    }
                    // Guzzle 5+
                    elseif (get_class($this->http) == 'GuzzleHttp\Client') {
                        $response = $this->http->request('POST', $this->url, array('form_params' => $payload));
                        $jsonResult = $response->getBody();
                    }
                    // Builtin http client request
                    elseif ($this->http instanceof BuiltinRestClient) {
                        $jsonResult = self::post($this->url, $payload);
                    }

                    if ($this->method == 'getAvailableDrivers') {
                        $this->availableDrivers = json_decode((string) $jsonResult, true);
                    } elseif ($this->method == 'getServerVersion') {
                        $res = json_decode((string) $jsonResult, true);
                        $this->serverVersion = isset($res['version']) ? $res['version'] : null;
                    } else {
                        $dispatcher->dispatch((string) $jsonResult);
                    }
                } catch (\Exception $e) {
                    $this->error->setMessage(strip_tags($e->getMessage()));
                }
            } else {
                $this->error->setMessage(sprintf(
                    'Dispatcher class must be instance of %s, %s given',
                    AbstractDispatcher::class,
                    (string) $this->dispatcher
                ));
            }
        } else {
            $this->error->setMessage(sprintf('Class %s not found', (string) $this->dispatcher));
        }
    }
1036008
protected function call()
    {
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER      => 1,
            CURLOPT_URL                 => $this->requestUrl[$this->format].$this->param,
            CURLOPT_SSL_VERIFYPEER      => false,
            CURLOPT_FAILONERROR         => true,
        ));

        $request = curl_exec($curl);

        if (empty($request)) {
            throw new \RuntimeException('cURL request retuened following error: '.curl_error($curl) );
        }

        curl_close($curl);

        return $request;
    }
1186312
public function getArray()
    {
        $contents = include $this->context;

        if (gettype($contents) != 'array') {
            throw new InvalidFileException($this->context . ' does not return a valid array');
        }

        return $contents;
    }
627125
private function _request()
    {
        $res = $this->_client->request(
            $this->_method,
            $this->_endpoint . '?' . $this->_query_parameters,
            [
                'headers' => $this->_headers,
                'http_errors' => false
            ]
        );
        return array(
            'code' => $res->getStatusCode(),
            'body' => new SimpleXMLElement($res->getBody())
        );
    }
948502
protected function getArrayRequest(): array
    {
        if (null === $this->arrayRequest) {
            return ArrayHelper::fromObject($this->getRequest()->call->params ?? []);
        }

        return $this->arrayRequest;
    }
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;
    }
562233
public function send()
    {
        if (empty($this->uri)) {
            throw new InvalidArgumentException('Invalid url for request.');
        }

        $customRequest = new Request();
        $customRequest->setHeaders($this->_headers);
        $this->httpClient->setRequest($customRequest);

        $this->httpClient->setMethod($this->method);
        $this->httpClient->setUri($this->uri);

        if ($this->method == Request::METHOD_GET) {
            if (!empty($this->params)) {
                $this->httpClient->setParameterGet($this->params);
            }
        }

        if ($this->method == Request::METHOD_POST) {
            if (!empty($this->params)) {
                $this->httpClient->setParameterPost($this->params);
            }
        }

        if ($this->postRawData !== null) {
            $this->httpClient->setRawBody($this->postRawData);
        }

        try {
            $this->response = $this->httpClient->send();
            if (!$this->response->isSuccess()) {
                throw new RuntimeException('Http request failure!');
            }
            $this->request = $this->httpClient->getRequest();

            return $this->response;

        } catch (HttpClientRuntimeException $exception) {
            throw new RuntimeException($exception->getMessage());
        } catch (HttpRuntimeException $exception) {
            throw new RuntimeException($exception->getMessage());
        }
    }
466955
public function sendRequest()
    {
        if ($this->getError()->hasError()) {
            return;
        }

        if (class_exists($this->dispatcher)) {
            $dispatcherClass = $this->dispatcher;
            $dispatcher = new $dispatcherClass($this->instance->getQuery());
            if ($dispatcher instanceof AbstractDispatcher) {
                try {
                    $client = new \SoapCLient($this->getUrl(), array('trace' => 1));

                    $config = $this->config->getRawConfig();
                    $sql = $this->instance->getQuery()->toString();
                    $limit = $this->instance->getQuery()->getLimit();
                    $offset = $this->instance->getQuery()->getOffset();
                    $single = $this->instance->getQuery()->isSingle();

                    if ($this->method == 'getAvailableDrivers') {
                        $this->availableDrivers = $client->getAvailableDrivers();
                    } elseif ($this->method == 'getServerVersion') {
                        $res = $client->getServerVersion();
                        $this->serverVersion = isset($res['version']) ? $res['version'] : null;
                    } else {
                        $response = $client->getResult($config, $sql, $limit, $offset, $single, $this->getKey(), 'array');
                        $dispatcher->dispatch($response);
                    }
                } catch (\SoapFault $e) {
                    $this->getError()->setMessage($e->getMessage());
                } catch (\Exception $e) {
                    $this->getError()->setMessage('Error server response');
                }
            } else {
                $this->getError()->setMessage(sprintf(
                    'Dispatcher class must be instance of %s, %s given',
                    AbstractDispatcher::class,
                    (string) $this->dispatcher
                ));
            }
        } else {
            $this->getError()->setMessage(sprintf('Class %s not found', (string) $this->dispatcher));
        }
    }
550070
protected function sendRequest()
    {
        $context = stream_context_create($this->request);
        $response = trim(file_get_contents($this->endpoint, FALSE, $context));
        $this->response = new Response($http_response_header, $response, $this->request);

        return $this->response;
    }
1311785
public function requestCommands(): array
    {
        if ($this->_requestCommands === null) {
            $reflection = new ReflectionClass($this);

            $commands = [];
            foreach ($reflection->getConstants() as $name => $value) {
                if (strpos($name, 'RC_') === 0) {
                    $commands[] = $value;
                }
            }

            return $this->_requestCommands = $commands;
        } else {
            return $this->_requestCommands;
        }
    }
191139
public function getRequest()
    {
        if (null === $this->request) {
            @trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
            // throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
        }

        return $this->request;
    }
706780
public function getLinks() : Array
    {
        if( ! $this->isJsonCheck() || $this->refresh === true )
        {
            $result = $this->getApiResult();

            if( ! is_object($result) )
            {
                throw new Exception\BadRequestURLException($this->address);
            }

            $this->putJsonContent($result);
        }

        $result = $this->decodeArrrayJsonContent();

        return $this->convertArrayByKeyValues($result);
    }
1079755
public function run()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;
        if (!$this->validateCsrfToken()) {
            throw new BadRequestHttpException(Yii::t('yii', 'Unable to verify your data submission.'));
        }
        if (Yii::$app->request->isAjax && $this->validateParams()) {
            $this->initSession();
            $code = $this->getVerifyCode();
            $remaining = $this->getRemainingRefreshTime(true);

            return [
//                 'code' => $code,
                'refreshTime' => $remaining,
                'hash1' => $this->generateValidationHash($code),
                'hash2' => $this->generateValidationHash($code),
            ];
        } else {
            return [];
        }
    }
569877
public function getList()
    {
        $request = new ListDirtyWordRequest();
        $response = new BaseResponse();
        return $this->client->sendRequest($request, $response);
    }