@param IHttpRequest $request

@return string
347813
protected function detectEnvFromRequestHeader(IHttpRequest $request) {
        $env = $request->getHeaders()->find('x-env');
        $request->getHeaders()->remove('x-env');

        return $env;
    }
1055578
private function _allowHeaders($request) {
        $allowHeaders = Configure::read('Cors.AllowHeaders');

        if ($allowHeaders === true) {
            return $request->getHeader('Access-Control-Request-Headers');
        }

        return implode(', ', (array) $allowHeaders);
    }
992807
protected function generateFromPsr7Request(Psr7Request $request) : string
    {
        $id = isset($this->request->getHeader('X-SIGNED-ID')[0]) ?
            $this->request->getHeader('X-SIGNED-ID')[0] : '';
        $timestamp = isset($this->request->getHeader('X-SIGNED-TIMESTAMP')[0]) ?
            $this->request->getHeader('X-SIGNED-TIMESTAMP')[0] : '';

        return $this->generate(
            (string) $id,
            (string) $this->request->getMethod(),
            (string) $timestamp,
            (string) $this->request->getUri(),
            (string) $this->request->getBody()
        );
    }
1100627
protected function processRequest(IHttpRequest $request) {
        // share request instance
        $this->container->set(
            [HttpRequest::class, IHttpRequest::class], $request
        );

        // boot application and the kernel
        $this->start();

        // notify listeners about an incoming http request
        $this->eventer->dispatch(new IncomingHttpRequestEvent($request));

        // allow listeners to handle the request and provide a valid http response
        $event = new HandleHttpRequestEvent($request);
        $this->eventer->dispatch($event);
        $response = $event->getResponse();

        // in case there is a valid http response
        if ($response instanceof IHttpResponse) {
            // give listeners a chance to modify it
            $this->eventer->dispatch(
                new HttpRequestHandledEvent($request, $response)
            );
        }

        // in case there was a valid http response,
        // return it as the final application result
        if ( ! $response instanceof IHttpResponse) {
            $response = new HttpResponse(
                HttpStatusCode::NOT_FOUND,
                s(
                    'Http request was not handled. ' .
                    'It seems like no one is registered to handle it. ' .
                    'You can solve this by handling the "%s" event and providing ' .
                    'a valid IHttpResponse i.e: $event->setResponse($response)',
                    HandleHttpRequestEvent::class
                )
            );
        }

        return $response;
    }
389157
protected function detectEnvFromUrlPath(IHttpRequest $request) {
        $env = $request->getUrl()->parse('/env={env}')->get('env');

        if ($env) {
            // remove environment from the url
            $cleanPath = str_replace(s('/env=%s', $env), '', $request->getUrl()->getPath());
            $request->getUrl()->setPath($cleanPath);
        }

        return $env;
    }
365922
private function preRequest(string $request): string
    {
        $result = $this->preRequest->handle(new TransportContainer($this, $request));

        if ($result instanceof TransportContainer) {
            return $result->getRequest();
        }

        throw new \RuntimeException();
    }
18668
public function index(HTTPRequest $request = null)
    {
        $form = $this->Form();
        if ($this->Content && $form && !$this->config()->disable_form_content_shortcode) {
            $hasLocation = stristr($this->Content, '$UserDefinedForm');
            if ($hasLocation) {
                /** @see Requirements_Backend::escapeReplacement */
                $formEscapedForRegex = addcslashes($form->forTemplate(), '\\$');
                $content = preg_replace(
                    '/(<p[^>]*>)?\\$UserDefinedForm(<\\/p>)?/i',
                    $formEscapedForRegex,
                    $this->Content
                );
                return [
                    'Content' => DBField::create_field('HTMLText', $content),
                    'Form' => ''
                ];
            }
        }

        return [
            'Content' => DBField::create_field('HTMLText', $this->Content),
            'Form' => $this->Form()
        ];
    }
1296109
public static function getMethodIfApiRequest($request)
    {
        $module = Common::getRequestVar('module', '', 'string', $request);
        $method = Common::getRequestVar('method', '', 'string', $request);

        $isApi = $module === 'API' && !empty($method) && (count(explode('.', $method)) === 2);
        return $isApi ? $method : null;
    }
1230519
public function renderRequest(RequestInterface $request)
    {
        $return  = '';
        $return .= sprintf("URL:     %s\n", $request->getUri());
        $return .= sprintf("METHOD:  %s\n", $request->getMethod());

        if ($request->getHeaders()) {
            $return .= 'HEADERS:';
        }

        $indent = false;
        foreach ($request->getHeaders() as $name => $values) {
            if ($indent) {
                $return .= str_repeat(' ', 8);
            }

            $return .= sprintf(" %s: %s\n", $name, implode(', ', $values));
            $indent  = true;
        }

        if ($body = (string) $request->getBody()) {
            $return .= 'BODY:    ';

            switch ($request->getHeaderLine('Content-Type')) {
                case 'application/json':
                    $return .= json_encode(json_decode($body, true), JSON_PRETTY_PRINT);
                    break;
                default:
                    $return .= $body;
                    break;
            }

            $return .= "\n";
        }

        return $return;
    }
405740
private function _allowOrigin($request) {
        $allowOrigin = Configure::read('Cors.AllowOrigin');
        $origin = $request->getHeader('Origin');

        if ($allowOrigin === true || $allowOrigin === '*') {
            return $origin;
        }

        if (is_array($allowOrigin)) {
            $origin = (array) $origin;

            foreach ($origin as $o) {
                if (in_array($o, $allowOrigin)) {
                    return $origin;
                }
            }

            return '';
        }

        return (string)$allowOrigin;
    }
1137306
public function handleRequest(IHttpClient $request) {
        $token = $this->getAuthorization(
        	$request->getUrl(),
        	$this->sharedAccessKeyName,
        	$this->sharedAccessKey
    	);

        $request->setHeader(Resources::AUTHENTICATION, $token);

        return $request;
    }
110555
public static function hostName(HTTPRequest $request = null)
    {
        $host = static::host($request);
        return parse_url($host, PHP_URL_HOST) ?: null;
    }
304398
public function getContentType(RequestInterface $request): string
    {
        try {
            $template = [
                self::CONTENT_TYPE_HTML => XHTMLTemplate::class,
                self::CONTENT_TYPE_JSON => JSONTemplate::class,
                self::CONTENT_TYPE_XML => XMLTemplate::class
            ];
            foreach (explode(",", $request->getHeaderLine(Request::HEADER_ACCEPT)) as $key) {
                if (array_key_exists($key, $template)) {
                    $this->attach(new $template[$key]);
                    return $key . "; charset=utf-8";
                }
            }
        } catch (BadMethodCallException $e) {
        }
        throw new ViewException(
            "Can't get content type in " . static::class
            . " for \"" . $request->getAttribute("action") . "\" action");
    }
679658
private function getOverrideMethod(ServerRequestInterface $request): string
    {
        if ($request->getMethod() === 'POST' && $this->parsedBodyParameter !== null) {
            $params = $request->getParsedBody();

            if (isset($params[$this->parsedBodyParameter])) {
                return strtoupper($params[$this->parsedBodyParameter]);
            }
        } elseif ($request->getMethod() === 'GET' && $this->queryParameter !== null) {
            $params = $request->getQueryParams();

            if (isset($params[$this->queryParameter])) {
                return strtoupper($params[$this->queryParameter]);
            }
        }

        return strtoupper($request->getHeaderLine(self::HEADER));
    }
169150
protected function transformRequestHeadersToString(RequestInterface $request): string
    {
        $message = vsprintf('%s %s HTTP/%s', [
            strtoupper($request->getMethod()),
            $request->getRequestTarget(),
            $request->getProtocolVersion(),
        ])."\r\n";

        foreach ($request->getHeaders() as $name => $values) {
            $message .= $name.': '.implode(', ', $values)."\r\n";
        }

        $message .= "\r\n";

        return $message;
    }
273747
public function getInvTypes(Request $request)
    {

        return response()->json([
            'results' => DB::table('invTypes')
                ->select('typeName as id', 'typeName as text')
                ->where('typeName', 'like', '%' . $request->q . '%')->get(),
        ]);

    }
356015
public function render($request)
    {
        if ($request->wantsJson()) {
            return $this->validInternalServerErrorJsonResponse($this, $this->message);
        } else {
            return redirect()->back()->with(['rafflesargentina.status.error' => $this->message]);
        }
    }