Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Unified Diff: sdk/lib/io/http_impl.dart

Issue 11498013: Follow the redirect rules from RFC 2616 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/io/http_redirect_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 5672bb52e6387313be3751a8b85e23d96570dbf7..c20047976499a04e562d540df2142b0fa2f07a2a 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -1286,10 +1286,16 @@ class _HttpClientResponse
String get reasonPhrase => _reasonPhrase;
bool get isRedirect {
- return statusCode == HttpStatus.MOVED_PERMANENTLY ||
- statusCode == HttpStatus.FOUND ||
- statusCode == HttpStatus.SEE_OTHER ||
- statusCode == HttpStatus.TEMPORARY_REDIRECT;
+ var method = _connection._request._method;
+ if (method == "GET" || method == "HEAD") {
+ return statusCode == HttpStatus.MOVED_PERMANENTLY ||
+ statusCode == HttpStatus.FOUND ||
+ statusCode == HttpStatus.SEE_OTHER ||
+ statusCode == HttpStatus.TEMPORARY_REDIRECT;
+ } else if (method == "POST") {
+ return statusCode == HttpStatus.SEE_OTHER;
+ }
+ return false;
}
List<Cookie> get cookies {
@@ -1346,7 +1352,12 @@ class _HttpClientResponse
}
// Drain body and redirect.
inputStream.onData = inputStream.read;
- _connection.redirect();
+ if (_statusCode == HttpStatus.SEE_OTHER &&
+ _connection._method == "POST") {
+ _connection.redirect("GET");
+ } else {
+ _connection.redirect();
+ }
} else {
throw new RedirectLimitExceededException(_connection._redirects);
}
« no previous file with comments | « no previous file | tests/standalone/io/http_redirect_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698