original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: 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
docstring_tokens: Builds the redirect request .