Sets compression headers.

@param ehough_shortstop_api_HttpRequest $request The request to modify.

@return void
438442
private function _setDefaultHeadersCompression(ehough_shortstop_api_HttpRequest $request)
    {
        if ($this->_isDebugEnabled) {

            $this->_logger->debug('Determining if HTTP compression is available...');
        }

        $header = $this->_httpContentDecoder->getAcceptEncodingHeaderValue();

        if ($header !== null) {

            if ($this->_isDebugEnabled) {

                $this->_logger->debug('HTTP decompression is available.');
            }

            $request->setHeader(ehough_shortstop_api_HttpRequest::HTTP_HEADER_ACCEPT_ENCODING, $header);

        } else {

            if ($this->_isDebugEnabled) {

                $this->_logger->debug('HTTP decompression is NOT available.');
            }
        }
    }
668258
private function addAuthenticationHeaders(Request $request) {
        $client = $request->getClient();

        // Get a GMT/UTC timestamp
        $timestamp = gmdate('Y-m-d\TH:i:s\Z');

        // Build the data to base the hash on
        $data = $request->getMethod() . '|' .
                $request->getUrl() . '|' .
                $client->getConfig('publicKey') . '|' .
                $timestamp;

        // Generate signature
        $signature = hash_hmac('sha256', $data, $client->getConfig('privateKey'));

        // Add relevant request headers (overwriting once that might already exist)
        $request->setHeader('X-Imbo-Authenticate-Signature', $signature);
        $request->setHeader('X-Imbo-Authenticate-Timestamp', $timestamp);
    }
583360
public function cssMapAction(Request $request)
    {
        $baseUrlContentFilter = $this->get('phlexible_gui.asset.base_url_content_filter');
        $baseUrlContentFilter->setBasePath($request->getBasePath());
        $baseUrlContentFilter->setBaseUrl($request->getBaseUrl());

        $cssBuilder = $this->get('phlexible_gui.asset.css_builder');

        $asset = $cssBuilder->build();

        return new BinaryFileResponse($asset->getMapAsset(), 200, array('Content-Type' => 'application/json;charset=UTF-8'));
    }
789377
protected function setRequestProperties(Request $request)
    {
        $this["basePath"] = $request->getBasePath();
        $this["baseUrl"] = $request->getSchemeAndHttpHost() . $this["basePath"];
    }
537927
private function withHeaders($request)
  {
    $headers = Config::get('cors.allowedHeaders');
    $methods = Config::get('cors.allowedMethods');
    $exposed = Config::get('cors.exposedHeaders');
    $maxAge  = Config::get('cors.maxAge');

    $request->headers->addMany([
      'Access-Control-Allow-Credentials' => Config::get('cors.supportsCredentials'),
      'Access-Control-Allow-Origin' => '*',
      'Access-Control-Allow-Headers' => implode(', ', $headers),
      'Access-Control-Allow-Methods' => implode(', ', $methods),
    ]);

    if (count($exposed) > 0) {
      $request->headers->add('Access-Control-Exposed-Headers', implode(', ', $exposed));
    }

    if ($maxAge > 0) {
      $request->headers->add('Access-Control-Max-Age', $maxAge);
    }
  }
307626
public function ensureFormDigest(RequestOptions $request)
    {
        if (!isset($this->contextWebInformation)) {
            $this->requestFormDigest();
        }
        $request->addCustomHeader("X-RequestDigest",$this->getContextWebInformation()->FormDigestValue);
    }
1081395
public function setRequest(Request $request)
    {
        $this->request = $request;

        $this->cachedRoot = null;
        $this->cachedScheme = null;
        $this->routeGenerator = null;
    }
354356
protected function addDefaultContextOptions(RequestInterface $request)
    {
        $this->setContextValue('http', 'method', $request->getMethod());
        $this->setContextValue('http', 'header', $request->getHeaderLines());
        // Force 1.0 for now until PHP fully support chunked transfer-encoding decoding
        $this->setContextValue('http', 'protocol_version', '1.0');
        $this->setContextValue('http', 'ignore_errors', true);
    }
942770
public function setRequest(Request $request)
    {
        $files = $request->files->all();

        $files = is_array($files) ? array_filter($files) : $files;

        $this->initialize(
            $request->query->all(), $request->request->all(), $request->attributes->all(),
            $request->cookies->all(), $files, $request->server->all(), $request->getContent()
        );

        if ($session = $request->getSession()){

            $this->setSession($session);

        }

        $this->setUserResolver($request->getUserResolver());

        $this->setRouteResolver($request->getRouteResolver());
    }
123980
public function handleFiles(Request &$request)
    {
        $files = $request->files->all();
        if(!empty($files)) {
            $metadata = $this->handlerService->handleFiles($files);
            $request->headers->add(['file-meta-data' => json_encode($metadata)]);
        }
    }
15949
protected function addDefaultParameters(&$request)
	{
		$defaultParameters = array(
			'all'=>1,
			'dir'=>'ASC',
			'start'=>0,
			'limit'=>999999999);

		foreach ($defaultParameters as $name=> $value)
			$request->getPost()->set($name, $value);
	}
384526
public function executeRequest(Google_Http_Request $request)
  {
    $default_options = stream_context_get_options(stream_context_get_default());

    $requestHttpContext = array_key_exists('http', $default_options) ?
        $default_options['http'] : array();

    if ($request->getPostBody()) {
      $requestHttpContext["content"] = $request->getPostBody();
    }

    $requestHeaders = $request->getRequestHeaders();
    if ($requestHeaders && is_array($requestHeaders)) {
      $headers = "";
      foreach ($requestHeaders as $k => $v) {
        $headers .= "$k: $v\r\n";
      }
      $requestHttpContext["header"] = $headers;
    }

    $requestHttpContext["method"] = $request->getRequestMethod();
    $requestHttpContext["user_agent"] = $request->getUserAgent();

    $requestSslContext = array_key_exists('ssl', $default_options) ?
        $default_options['ssl'] : array();

    if (!array_key_exists("cafile", $requestSslContext)) {
      $requestSslContext["cafile"] = dirname(__FILE__) . '/cacerts.pem';
    }

    $options = array(
        "http" => array_merge(
            self::$DEFAULT_HTTP_CONTEXT,
            $requestHttpContext
        ),
        "ssl" => array_merge(
            self::$DEFAULT_SSL_CONTEXT,
            $requestSslContext
        )
    );

    $context = stream_context_create($options);

    $url = $request->getUrl();

    if ($request->canGzip()) {
      $url = self::ZLIB . $url;
    }

    $this->client->getLogger()->debug(
        'Stream request',
        array(
            'url' => $url,
            'method' => $request->getRequestMethod(),
            'headers' => $requestHeaders,
            'body' => $request->getPostBody()
        )
    );

    // We are trapping any thrown errors in this method only and
    // throwing an exception.
    $this->trappedErrorNumber = null;
    $this->trappedErrorString = null;

    // START - error trap.
    set_error_handler(array($this, 'trapError'));
    $fh = fopen($url, 'r', false, $context);
    restore_error_handler();
    // END - error trap.

    if ($this->trappedErrorNumber) {
      $error = sprintf(
          "HTTP Error: Unable to connect: '%s'",
          $this->trappedErrorString
      );

      $this->client->getLogger()->error('Stream ' . $error);
      throw new Google_IO_Exception($error, $this->trappedErrorNumber);
    }

    $response_data = false;
    $respHttpCode = self::UNKNOWN_CODE;
    if ($fh) {
      if (isset($this->options[self::TIMEOUT])) {
        stream_set_timeout($fh, $this->options[self::TIMEOUT]);
      }

      $response_data = stream_get_contents($fh);
      fclose($fh);

      $respHttpCode = $this->getHttpResponseCode($http_response_header);
    }

    if (false === $response_data) {
      $error = sprintf(
          "HTTP Error: Unable to connect: '%s'",
          $respHttpCode
      );

      $this->client->getLogger()->error('Stream ' . $error);
      throw new Google_IO_Exception($error, $respHttpCode);
    }

    $responseHeaders = $this->getHttpResponseHeaders($http_response_header);

    $this->client->getLogger()->debug(
        'Stream response',
        array(
            'code' => $respHttpCode,
            'headers' => $responseHeaders,
            'body' => $response_data,
        )
    );

    return array($response_data, $responseHeaders, $respHttpCode);
  }
704090
private static function fillCurrentHeaders(self $request)
    {
        $headers = [];

        //Native method exists?
        if (function_exists('getallheaders')) {

            //try to use it
            if (($headers = getallheaders()) === false) {
                $headers = [];
            }
        }

        //No header captured yet? Try to get it myself
        if (empty($headers)) {

            /*
             * Based on a user note provided by joyview
             * at http://php.net/manual/en/function.getallheaders.php
             */
            foreach ($_SERVER as $key => $value) {
                if (substr($key, 0, 5) === 'HTTP_') {
                    $newKey = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
                    $headers[$newKey] = $value;
                }
            }
        }

        $request->setHeaders($headers);
    }
576126
public function handleRequest(Request $request): void
    {
        $this->getForm()->handleRequest($request);
        $this->handleForm($request->get('page'));
    }
266670
protected function doRequest($request)
    {
        $headers = array();
        foreach ($request->getServer() as $key => $val) {
            $key = strtolower(str_replace('_', '-', $key));
            $contentHeaders = array('content-length' => true, 'content-md5' => true, 'content-type' => true);
            if (0 === strpos($key, 'http-')) {
                $headers[substr($key, 5)] = $val;
            }
            // CONTENT_* are not prefixed with HTTP_
            elseif (isset($contentHeaders[$key])) {
                $headers[$key] = $val;
            }
        }

        $cookies = CookieJar::fromArray(
            $this->getCookieJar()->allRawValues($request->getUri()),
            parse_url($request->getUri(), PHP_URL_HOST)
        );

        $requestOptions = array(
            'cookies' => $cookies,
            'allow_redirects' => false,
            'auth' => $this->auth,
        );

        if (!in_array($request->getMethod(), array('GET', 'HEAD'))) {
            if (null !== $content = $request->getContent()) {
                $requestOptions['body'] = $content;
            } else {
                if ($files = $request->getFiles()) {
                    $requestOptions['multipart'] = [];

                    $this->addPostFields($request->getParameters(), $requestOptions['multipart']);
                    $this->addPostFiles($files, $requestOptions['multipart']);
                } else {
                    $requestOptions['form_params'] = $request->getParameters();
                }
            }
        }

        if (!empty($headers)) {
            $requestOptions['headers'] = $headers;
        }

        $method = $request->getMethod();
        $uri = $request->getUri();

        foreach ($this->headers as $name => $value) {
            $requestOptions['headers'][$name] = $value;
        }

        // Let BrowserKit handle redirects
        try {
            $response = $this->getClient()->request($method, $uri, $requestOptions);
        } catch (RequestException $e) {
            $response = $e->getResponse();
            if (null === $response) {
                throw $e;
            }
        }

        return $this->createResponse($response);
    }
649552
public function setCustomHeaders(array $headers)
    {
        foreach ($headers as $k => &$v) {
            if (strpos($v, ':') === false) {
                $v = $k.': '.$v;
            }
        }
        $this->headers = $headers;
    }
10338
protected function setRouteInfo($request)
    {
        $this->route_info = Route::getWebInfo($request);
        if (!$this->route_info['controller'] || !$this->route_info['action']) {
            $this->route_info['controller'] = 'index';
            $this->route_info['action'] = 'index';
            $home = Lb::app()->getHome();
            if (isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
                $this->route_info['controller'] = $home['controller'];
                $this->route_info['action'] = $home['action'];
            }
        }
    }