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

Unified Diff: tests/standalone/src/HttpTest.dart

Issue 9500014: Add statusCode and reasonPhrase getters and setters to the HttpResponse interface (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 10 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 | « runtime/bin/http_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/HttpTest.dart
diff --git a/tests/standalone/src/HttpTest.dart b/tests/standalone/src/HttpTest.dart
index df2c2c38385b2ea12ad5fd42d7364acab85d83f6..62e2585be8af3b67097e0f6cbc27439bfdea8d6e 100644
--- a/tests/standalone/src/HttpTest.dart
+++ b/tests/standalone/src/HttpTest.dart
@@ -117,6 +117,13 @@ class TestServer extends Isolate {
response.outputStream.close();
}
+ // Return a 301 with a custom reason phrase.
+ void _reasonForMovingHandler(HttpRequest request, HttpResponse response) {
+ response.statusCode = HttpStatus.MOVED_PERMANENTLY;
+ response.reasonPhrase = "Don't come looking here any more";
+ response.outputStream.close();
+ }
+
void main() {
// Setup request handlers.
_requestHandlers = new Map();
@@ -127,6 +134,10 @@ class TestServer extends Isolate {
(HttpRequest request, HttpResponse response) {
_zeroToTenHandler(request, response);
};
+ _requestHandlers["/reasonformoving"] =
+ (HttpRequest request, HttpResponse response) {
+ _reasonForMovingHandler(request, response);
+ };
this.port.receive((var message, SendPort replyTo) {
if (message.isStart) {
@@ -372,6 +383,23 @@ void test404() {
}
+void testReasonPhrase() {
+ TestServerMain testServerMain = new TestServerMain();
+ testServerMain.setServerStartedHandler((int port) {
+ HttpClient httpClient = new HttpClient();
+ HttpClientConnection conn =
+ httpClient.get("127.0.0.1", port, "/reasonformoving");
+ conn.responseHandler = (HttpClientResponse response) {
+ Expect.equals(HttpStatus.MOVED_PERMANENTLY, response.statusCode);
+ Expect.equals("Don't come looking here any more", response.reasonPhrase);
+ httpClient.shutdown();
+ testServerMain.shutdown();
+ };
+ });
+ testServerMain.start();
+}
+
+
void main() {
testStartStop();
testGET();
@@ -382,4 +410,5 @@ void main() {
testReadShort(true);
testReadShort(false);
test404();
+ testReasonPhrase();
}
« no previous file with comments | « runtime/bin/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698