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

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

Issue 21411003: Add redirect method to HttpResponse (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 5 months 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 | « sdk/lib/io/http.dart ('k') | 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 3af4000b2f300237c9b4346b3c006f582f1d6408..3cf6cde93bd2900c1d7b2bf5078f362b4f546004 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -708,6 +708,13 @@ class _HttpResponse extends _HttpOutboundMessage<HttpResponse>
_reasonPhrase = reasonPhrase;
}
+ Future redirect(Uri location, {int status: HttpStatus.MOVED_TEMPORARILY}) {
+ if (_headersWritten) throw new StateError("Header already sent");
+ statusCode = status;
+ headers.set("Location", location.toString());
+ return close();
+ }
+
Future<Socket> detachSocket() {
if (_headersWritten) throw new StateError("Headers already sent");
deadline = null; // Be sure to stop any deadline.
@@ -1908,7 +1915,7 @@ class _HttpServer extends Stream<HttpRequest> implements HttpServer {
backlog: backlog,
requestClientCertificate: requestClientCertificate)
.then((socket) {
- return new _HttpServer._(socket, true);
+ return new _HttpServer._(socket, true);
});
}
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/http_redirect_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698