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

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

Issue 9616004: Add handling of the HTTP header "Host" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 9 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/io/HttpTest.dart
diff --git a/tests/standalone/src/io/HttpTest.dart b/tests/standalone/src/io/HttpTest.dart
index 62c5bcdd0fad69e6ab791abfd748dd85b18d3289..2f5907cb61b3a5599876cd447f1cfb9650676e75 100644
--- a/tests/standalone/src/io/HttpTest.dart
+++ b/tests/standalone/src/io/HttpTest.dart
@@ -124,6 +124,13 @@ class TestServer extends Isolate {
response.outputStream.close();
}
+ // Return a 301 with a custom reason phrase.
+ void _hostHandler(HttpRequest request, HttpResponse response) {
+ Expect.equals("www.dartlang.org:1234", request.headers["host"]);
+ response.statusCode = HttpStatus.OK;
+ response.outputStream.close();
+ }
+
void main() {
// Setup request handlers.
_requestHandlers = new Map();
@@ -138,6 +145,10 @@ class TestServer extends Isolate {
(HttpRequest request, HttpResponse response) {
_reasonForMovingHandler(request, response);
};
+ _requestHandlers["/host"] =
+ (HttpRequest request, HttpResponse response) {
+ _hostHandler(request, response);
+ };
this.port.receive((var message, SendPort replyTo) {
if (message.isStart) {
@@ -400,6 +411,41 @@ void testReasonPhrase() {
}
+void testHost() {
+ TestServerMain testServerMain = new TestServerMain();
+ testServerMain.setServerStartedHandler((int port) {
+ HttpClient httpClient = new HttpClient();
+ HttpClientConnection conn =
+ httpClient.get("127.0.0.1", port, "/host");
+ conn.onRequest = (HttpClientRequest request) {
+ Expect.equals("127.0.0.1:$port", request.headers["host"]);
+ request.host = "www.dartlang.com";
+ Expect.equals("www.dartlang.com:$port", request.headers["host"]);
+ request.port = 1234;
+ Expect.equals("www.dartlang.com:1234", request.headers["host"]);
+ request.port = HttpClient.DEFAULT_HTTP_PORT;
+ Expect.equals("www.dartlang.com", request.headers["host"]);
+ request.setHeader("Host", "www.dartlang.org");
+ Expect.equals("www.dartlang.org", request.host);
+ Expect.equals(HttpClient.DEFAULT_HTTP_PORT, request.port);
+ request.setHeader("Host", "www.dartlang.org:");
+ Expect.equals("www.dartlang.org", request.host);
+ Expect.equals(HttpClient.DEFAULT_HTTP_PORT, request.port);
+ request.setHeader("Host", "www.dartlang.org:1234");
+ Expect.equals("www.dartlang.org", request.host);
+ Expect.equals(1234, request.port);
+ request.outputStream.close();
+ };
+ conn.onResponse = (HttpClientResponse response) {
+ Expect.equals(HttpStatus.OK, response.statusCode);
+ httpClient.shutdown();
+ testServerMain.shutdown();
+ };
+ });
+ testServerMain.start();
+}
+
+
void main() {
testStartStop();
testGET();
@@ -411,4 +457,5 @@ void main() {
testReadShort(false);
test404();
testReasonPhrase();
+ testHost();
}
« 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