protected function buildRedirectRequest(RequestInterface $request, UriInterface $uri, $statusCode)
    {
        $request = $request->withUri($uri);

        if (false !== $this->redirectCodes[$statusCode]['switch'] && !in_array($request->getMethod(), $this->redirectCodes[$statusCode]['switch']['unless'])) {
            $request = $request->withMethod($this->redirectCodes[$statusCode]['switch']['to']);
        }

        if (is_array($this->preserveHeader)) {
            $headers = array_keys($request->getHeaders());

            foreach ($headers as $name) {
                if (!in_array($name, $this->preserveHeader)) {
                    $request = $request->withoutHeader($name);
                }
            }
        }

        return $request;
    }
protected function buildRedirectRequest(RequestInterface $request, UriInterface $uri, $statusCode)
    {
        $request = $request->withUri($uri);

        if (false !== $this->redirectCodes[$statusCode]['switch'] && !in_array($request->getMethod(), $this->redirectCodes[$statusCode]['switch']['unless'])) {
            $request = $request->withMethod($this->redirectCodes[$statusCode]['switch']['to']);
        }

        if (is_array($this->preserveHeader)) {
            $headers = array_keys($request->getHeaders());

            foreach ($headers as $name) {
                if (!in_array($name, $this->preserveHeader)) {
                    $request = $request->withoutHeader($name);
                }
            }
        }

        return $request;
    }
protected function buildRedirectRequest ( RequestInterface $ request , UriInterface $ uri , $ statusCode ) { $ request = $ request -> withUri ( $ uri ) ; if ( false !== $ this -> redirectCodes [ $ statusCode ] [ 'switch' ] && ! in_array ( $ request -> getMethod ( ) , $ this -> redirectCodes [ $ statusCode ] [ 'switch' ] [ 'unless' ] ) ) { $ request = $ request -> withMethod ( $ this -> redirectCodes [ $ statusCode ] [ 'switch' ] [ 'to' ] ) ; } if ( is_array ( $ this -> preserveHeader ) ) { $ headers = array_keys ( $ request -> getHeaders ( ) ) ; foreach ( $ headers as $ name ) { if ( ! in_array ( $ name , $ this -> preserveHeader ) ) { $ request = $ request -> withoutHeader ( $ name ) ; } } } return $ request ; }
Builds the redirect request.

@param RequestInterface $request    Original request
@param UriInterface     $uri        New uri
@param int              $statusCode Status code from the redirect response

@return MessageInterface|RequestInterface
Builds the redirect request .