@param RequestInterface  $request
@param array             $options
@param ResponseInterface $response

@return RequestInterface
322774
public function modifyRequest(
        RequestInterface $request,
        array $options,
        ResponseInterface $response
    ) {
        // Request modifications to apply.
        $modify = [];
        $protocols = $options['allow_redirects']['protocols'];

        // Use a GET request if this is an entity enclosing request and we are
        // not forcing RFC compliance, but rather emulating what all browsers
        // would do.
        $statusCode = $response->getStatusCode();
        if ($statusCode == 303 ||
            ($statusCode <= 302 && $request->getBody() && !$options['allow_redirects']['strict'])
        ) {
            $modify['method'] = 'GET';
            $modify['body'] = '';
        }

        $modify['uri'] = $this->redirectUri($request, $response, $protocols);
        Psr7\rewind_body($request);

        // Add the Referer header if it is told to do so and only
        // add the header if we are not redirecting from https to http.
        if ($options['allow_redirects']['referer']
            && $modify['uri']->getScheme() === $request->getUri()->getScheme()
        ) {
            $uri = $request->getUri()->withUserInfo('', '');
            $modify['set_headers']['Referer'] = (string) $uri;
        } else {
            $modify['remove_headers'][] = 'Referer';
        }

        // Remove Authorization header if host is different.
        if ($request->getUri()->getHost() !== $modify['uri']->getHost()) {
            $modify['remove_headers'][] = 'Authorization';
        }

        return Psr7\modify_request($request, $modify);
    }
738305
protected function createHeaders(RequestInterface $request, array $options)
	{
		$headers = [];
		$body = $request->getBody();
		$size = $body->getSize();

		foreach ($request->getHeaders() as $header => $values)
		{
			foreach ((array) $values as $value)
			{
				$headers[] = sprintf('%s: %s', $header, $value);
			}
		}

		if ( ! $request->hasHeader('Transfer-Encoding') && $size === null)
		{
			$headers[] = 'Transfer-Encoding: chunked';
		}

		if ( ! $request->hasHeader('Expect') && in_array($request->getMethod(), ['POST', 'PUT']))
		{
			if ($request->getProtocolVersion() < 2.0 && ! $body->isSeekable() || $size === null || $size > 1048576)
			{
				$headers[] = 'Expect: 100-Continue';
			}
			else
			{
				$headers[] = 'Expect: ';
			}
		}

		return $headers;
	}
287374
protected function sendRequest($url, $method = 'get', array $options = [])
    {
        return $this->send(
          new Request($method, $url),
          $this->client,
          $options
        );
    }
346183
public function requestRaw(string $url, string $method = 'GET', array $options = [])
    {
        return Response::buildFromPsrResponse($this->request($url, $method, $options, true));
    }
571228
public function makeRequest($url, $options = [], $parseResponse = true)
    {
        $headers = isset($options['headers']) ? $options['headers'] : [];
        $options['headers'] = array_merge($this->getExtraApiHeaders(), $headers);

        return parent::makeRequest($url, $options, $parseResponse);
    }
886762
protected function onRejected(RequestInterface $request, array $options)
    {
        return function ($reason) use ($request, $options) {
            // If was bad response exception, test if we retry based on the response headers
            if ($reason instanceof BadResponseException) {
                if ($this->shouldRetryHttpResponse($options, $reason->getResponse())) {
                    return $this->doRetry($request, $options, $reason->getResponse());
                }
            // If this was a connection exception, test to see if we should retry based on connect timeout rules
            } elseif ($reason instanceof ConnectException) {
                // If was another type of exception, test if we should retry based on timeout rules
                if ($this->shouldRetryConnectException($reason, $options)) {
                    return $this->doRetry($request, $options);
                }
            }

            // If made it here, then we have decided not to retry the request
            return \GuzzleHttp\Promise\rejection_for($reason);
        };
    }
639146
public function process(Request $request, array &$options = array())
    {
        if (!isset($options['article']) || !$options['article'] || !$options['article'] instanceof Article) {
            throw new NotFoundHttpException('Cannot retrieve article.');
        }

        /** @var Article $article */
        $article = $options['article'];
        if ($request->isMethod('post')) {
            $parameters = array_keys($request->request->all());
            if (!$this->chain->has($parameters[0])) {
                throw new \InvalidArgumentException(sprintf('You must implement a vince_cms.processor tagged service for form %s.', $parameters[0]));
            } else {
                $return = $this->chain->get($parameters[0])->setOptions($options)->process($request);

                // Processor returns a Response object
                if (is_object($return) && $return instanceof Response) {
                    return $return;

                // Processor returns Form object
                } elseif (is_object($return) && $return instanceof Form) {
                    $options['form'] = $return->createView();

                    // Response is build in controller
                    return false;

                // Processor returns array
                } elseif (is_array($return)) {
                    $options = array_merge($return, $options);

                    // Response is build in controller
                    return false;

                // Processor returns boolean
                } elseif (is_bool($return)) {
                    return !$return ?: new RedirectResponse($this->router->generate($article->getRouteName()), 302);
                }
            }
        }

        return false;
    }
908683
public function request($url, $method = 'GET', $options = [])
    {
        $method = strtoupper($method);

        $options = array_merge(self::$defaults, $options);

        Log::debug('Client Request:', compact('url', 'method', 'options'));

        $options['handler'] = $this->getHandler();

        if (property_exists($this, 'baseUri') && !is_null($this->baseUri)) {
            $options['base_uri'] = $this->baseUri;
        }

        $response = $this->getClient()->request($method, $url, $options);

        Log::debug('API response:', [
            'Status' => $response->getStatusCode(),
            'Reason' => $response->getReasonPhrase(),
            'Headers' => $response->getHeaders(),
            'Body' => strval($response->getBody()),
        ]);

        return $response;
    }
1249794
public function getRequest($method, $url, array $options = [])
    {
        return $this->createRequest($method, $url, null, $options);
    }
762882
public function send($request, $response, $options = [])
    {
        $this->push($request, $response, $options);
        $result = $this->flush(10, $options);
        return $response;
    }
324756
public function send(RequestInterface $request, array $options = [])
    {
        try {
            return $this->client->send($request, $options);
        } catch (TransferException $e) {
            throw new TransportException($e->getMessage(), $e->getCode(), $e);
        }
    }
415966
public function send(IHttpClientOptions $options, IHttpRequest $httpRequest) {
        $requestBuilder = new RequestBuilder($httpRequest, $options);
        $responseBuilder = $requestBuilder->send();
        $httpResponse = $responseBuilder->createResponse();
        $requestBuilder->close();

        return $httpResponse;
    }
167048
public function processResponse(RequestInterface $request, array $options, ResponseInterface $response)
    {
        $response = $response
            ->withHeader('X-Blackfire-Profile-Uuid', $request->getHeader('X-Blackfire-Profile-Uuid'))
            ->withHeader('X-Blackfire-Profile-Url', $request->getHeader('X-Blackfire-Profile'))
        ;

        if (!$response->hasHeader('X-Blackfire-Response')) {
            if (null !== $this->logger) {
                $this->logger->warning('Profile request failed.', array(
                    'profile-uuid' => $request->getHeader('X-Blackfire-Profile-Uuid'),
                    'profile-url' => $request->getHeader('X-Blackfire-Profile-Url'),
                ));
            }

            return $response;
        }

        parse_str($response->getHeader('X-Blackfire-Response')[0], $values);

        if (!isset($values['continue']) || 'true' !== $values['continue']) {
            if (null !== $this->logger) {
                $this->logger->debug('Profile request succeeded.', array(
                    'profile-uuid' => $request->getHeader('X-Blackfire-Profile-Uuid'),
                    'profile-url' => $request->getHeader('X-Blackfire-Profile'),
                ));
            }

            return $response;
        }

        Psr7\rewind_body($request);

        /* @var PromiseInterface|ResponseInterface $promise */
        return $this($request, $options);
    }
410522
private function requestAPI($method, $url, array $options = [])
    {
        try {
            return $this->sendRequest((string)$method, (string)$url, $options);
        } catch (SessionWasExpiredException $e) {
            return $this->sendRequest((string)$method, (string)$url, $options);
        } catch (ClientException $e) {
            throw new BunqException($e);
        }
    }
938623
public function send(RequestInterface $request, ResponseInterface $response)
    {
        $procedure = $this->procedureLoader->load($this->procedure);

        $this->procedureCompiler->compile($procedure, $request);

        $procedure->run($request, $response);

        return $response;
    }
1342406
public function send($method, $uri, array $options = [])
    {
        $this->calls[] = array('send', $method, $uri, $options);

        return new Response();
    }
11129
protected function addRequestBodyOptions(RequestInterface $request, array $options)
	{
		/*
		 * HTTP methods that cannot have payload:
		 * - GET   => cURL will automatically change method to PUT or POST if we
		 *            set CURLOPT_UPLOAD or CURLOPT_POSTFIELDS.
		 * - HEAD  => cURL treats HEAD as GET request with a same restrictions.
		 * - TRACE => According to RFC7231: a client MUST NOT send a message body
		 *            in a TRACE request.
		 */
		$http_methods = [
			'GET',
			'HEAD',
			'TRACE',
		];

		if (!in_array($request->getMethod(), $http_methods, true)) {
			$body      = $request->getBody();
			$body_size = $body->getSize();

			if ($body_size !== 0) {
				if ($body->isSeekable()) {
					$body->rewind();
				}

				if ($body_size === null || $body_size > self::$MAX_BODY_SIZE) {
					$options[CURLOPT_UPLOAD] = true;

					if ($body_size !== null) {
						$options[CURLOPT_INFILESIZE] = $body_size;
					}

					$options[CURLOPT_READFUNCTION] = function ($ch, $fd, $len) use ($body) {
						return $body->read($len);
					};
				}
				else {
					$options[CURLOPT_POSTFIELDS] = (string)$body;
				}
			}
		}

		if ($request->getMethod() === 'HEAD') {
			$options[CURLOPT_NOBODY] = true;
		}
		else if ($request->getMethod() !== 'GET') {
			$options[CURLOPT_CUSTOMREQUEST] = $request->getMethod();
		}

		return $options;
	}