Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: request options not pass through #1139

Merged
merged 1 commit into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions kraken/lib/src/foundation/http_client_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions kraken/test/fixtures/GET_301
Original file line number Diff line number Diff line change
@@ -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: *

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<h1>301 Moved Permanently</h1>
<p>The requested resource has been assigned a new permanent URI.</p>
<hr/>Powered by Tengine</body>
</html>
9 changes: 9 additions & 0 deletions kraken/test/src/foundation/http_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}