src/Request/RequestClient.php
public static function onHeaderLocation(Request $request, Response $response, RequestClient $client)
    {
        if ($client->follow
            && in_array($response->status, [
                Http::CREATED,
                Http::MOVED_PERMANENTLY,
                Http::FOUND,
                Http::SEE_OTHER,
                Http::TEMPORARY_REDIRECT,
            ])
        )
        {
            switch ($response->status)
            {
                default:
                case Http::MOVED_PERMANENTLY:
                case Http::TEMPORARY_REDIRECT:
                    $followMethod = $request->method;
                    break;
                case Http::CREATED:
                case Http::SEE_OTHER:
                    $followMethod = Http::GET;
                    break;
                case Http::FOUND:
                    if ($client->strictRedirect)
                    {
                        $followMethod = $request->method;
                    }
                    else
                    {
                        $followMethod = Http::GET;
                    }
                    break;
            }

            $origHeaders = $request->headers();
            $followHeaders = array_intersect_assoc($origHeaders, array_fill_keys($client->followHeaders, true));

            $followRequest = Request::factory($response->headers('Location'));
            $followRequest->method = $followMethod;
            $followRequest->headers($followHeaders);


            if ($followMethod !== Http::GET)
            {
                $followRequest->body = $request->body;
            }

            return $followRequest;
        }

        return null;
    }
public static function onHeaderLocation(Request $request, Response $response, RequestClient $client)
    {
        if ($client->follow
            && in_array($response->status, [
                Http::CREATED,
                Http::MOVED_PERMANENTLY,
                Http::FOUND,
                Http::SEE_OTHER,
                Http::TEMPORARY_REDIRECT,
            ])
        )
        {
            switch ($response->status)
            {
                default:
                case Http::MOVED_PERMANENTLY:
                case Http::TEMPORARY_REDIRECT:
                    $followMethod = $request->method;
                    break;
                case Http::CREATED:
                case Http::SEE_OTHER:
                    $followMethod = Http::GET;
                    break;
                case Http::FOUND:
                    if ($client->strictRedirect)
                    {
                        $followMethod = $request->method;
                    }
                    else
                    {
                        $followMethod = Http::GET;
                    }
                    break;
            }

            $origHeaders = $request->headers();
            $followHeaders = array_intersect_assoc($origHeaders, array_fill_keys($client->followHeaders, true));

            $followRequest = Request::factory($response->headers('Location'));
            $followRequest->method = $followMethod;
            $followRequest->headers($followHeaders);


            if ($followMethod !== Http::GET)
            {
                $followRequest->body = $request->body;
            }

            return $followRequest;
        }

        return null;
    }
跳转状态码的处理

@param Request       $request
@param Response      $response
@param RequestClient $client
@return null|Request