diff --git a/kraken/lib/src/foundation/http_client_request.dart b/kraken/lib/src/foundation/http_client_request.dart index a358855c14..067ff673b5 100644 --- a/kraken/lib/src/foundation/http_client_request.dart +++ b/kraken/lib/src/foundation/http_client_request.dart @@ -225,6 +225,14 @@ class ProxyHttpClientRequest extends HttpClientRequest { _httpHeaders.forEach(backendRequest.headers.set); _httpHeaders.clear(); + // Assign configs for backend request. + backendRequest + ..bufferOutput = bufferOutput + ..contentLength = contentLength + ..followRedirects = followRedirects + ..persistentConnection = persistentConnection + ..maxRedirects = maxRedirects; + _backendRequest = backendRequest; return backendRequest; } diff --git a/kraken/test/fixtures/GET_301 b/kraken/test/fixtures/GET_301 new file mode 100644 index 0000000000..e4f0d94ce1 --- /dev/null +++ b/kraken/test/fixtures/GET_301 @@ -0,0 +1,15 @@ +HTTP/1.1 301 Moved Permanently +Content-Type: text/html +Content-Length: 262 +Connection: keep-alive +Location: https://www.taobao.com/ +Timing-Allow-Origin: * + + + +301 Moved Permanently + +

301 Moved Permanently

+

The requested resource has been assigned a new permanent URI.

+
Powered by Tengine + diff --git a/kraken/test/src/foundation/http_cache.dart b/kraken/test/src/foundation/http_cache.dart index 808caad50c..383fc75ab2 100644 --- a/kraken/test/src/foundation/http_cache.dart +++ b/kraken/test/src/foundation/http_cache.dart @@ -197,5 +197,14 @@ void main() { expect(response!.headers.value('cache-hits'), 'HIT'); expect(response.headers.value('x-custom-header'), 'hello-world'); }); + + test('Work with followRedirects: false', () async { + var req = await httpClient.openUrl('GET', + server.getUri('301')); + req.followRedirects = false; + var res = await req.close(); + + expect(res.statusCode, 301); + }); }); }