From 067c40817dd5691785ae2e045efcc47fb9f2baf9 Mon Sep 17 00:00:00 2001 From: twosee Date: Thu, 7 May 2020 17:33:33 +0800 Subject: [PATCH] Optimization for redirect response --- src/Response.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Response.php b/src/Response.php index 3f3ad2e..de5aa65 100755 --- a/src/Response.php +++ b/src/Response.php @@ -7,7 +7,6 @@ namespace Swlib\Saber; -use Swlib\Http\BufferStream; use Swlib\Http\CookiesManagerTrait; use Swlib\Http\Exception\BadResponseException; use Swlib\Http\Exception\ClientException; @@ -18,7 +17,6 @@ use Swlib\Http\StreamInterface; use Swlib\Util\StringDataParserTrait; use Swlib\Util\SpecialMarkTrait; -use Swlib\Http\Status; use function Swlib\Http\stream_for; class Response extends \Swlib\Http\Response @@ -67,7 +65,7 @@ function __construct(Request $request) // enable auto iconv if ($request->charset_source && strcasecmp($request->charset_source, 'auto') !== 0) { $charset_source = $request->charset_source; - } elseif ( + } /** @noinspection PhpStatementHasEmptyBodyInspection */ elseif ( ($contentType = $request->client->headers['content-type'] ?? '') && ($charset_source = explode('=', $contentType)[1] ?? null) ) { @@ -111,7 +109,8 @@ function __construct(Request $request) $this->success = true; break; case 3: - if ($this->statusCode === Status::NOT_MODIFIED) { + if (!$this->hasHeader('Location')) { + /* not a redirect response */ $this->success = true; break; }