| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // | 4 // |
| 5 // VMOptions= | 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 | 9 |
| 10 #import("dart:isolate"); | 10 #import("dart:isolate"); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 Expect.equals(1, request.headers["Host"].length); | 129 Expect.equals(1, request.headers["Host"].length); |
| 130 Expect.equals("www.dartlang.org:1234", request.headers["Host"][0]); | 130 Expect.equals("www.dartlang.org:1234", request.headers["Host"][0]); |
| 131 Expect.equals("www.dartlang.org", request.headers.host); | 131 Expect.equals("www.dartlang.org", request.headers.host); |
| 132 Expect.equals(1234, request.headers.port); | 132 Expect.equals(1234, request.headers.port); |
| 133 response.statusCode = HttpStatus.OK; | 133 response.statusCode = HttpStatus.OK; |
| 134 response.outputStream.close(); | 134 response.outputStream.close(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Set the "Expires" header using the expires property. | 137 // Set the "Expires" header using the expires property. |
| 138 void _expires1Handler(HttpRequest request, HttpResponse response) { | 138 void _expires1Handler(HttpRequest request, HttpResponse response) { |
| 139 Date date = | 139 Date date = new Date(1999, Date.JUN, 11, 18, 46, 53, 0, isUtc: true); |
| 140 new Date.withTimeZone( | |
| 141 1999, Date.JUN, 11, 18, 46, 53, 0, new TimeZone.utc()); | |
| 142 response.headers.expires = date; | 140 response.headers.expires = date; |
| 143 Expect.equals(date, response.headers.expires); | 141 Expect.equals(date, response.headers.expires); |
| 144 response.outputStream.close(); | 142 response.outputStream.close(); |
| 145 } | 143 } |
| 146 | 144 |
| 147 // Set the "Expires" header. | 145 // Set the "Expires" header. |
| 148 void _expires2Handler(HttpRequest request, HttpResponse response) { | 146 void _expires2Handler(HttpRequest request, HttpResponse response) { |
| 149 response.headers.set("Expires", "Fri, 11 Jun 1999 18:46:53 GMT"); | 147 response.headers.set("Expires", "Fri, 11 Jun 1999 18:46:53 GMT"); |
| 150 Date date = | 148 Date date = new Date(1999, Date.JUN, 11, 18, 46, 53, 0, isUtc: true); |
| 151 new Date.withTimeZone( | |
| 152 1999, Date.JUN, 11, 18, 46, 53, 0, new TimeZone.utc()); | |
| 153 Expect.equals(date, response.headers.expires); | 149 Expect.equals(date, response.headers.expires); |
| 154 response.outputStream.close(); | 150 response.outputStream.close(); |
| 155 } | 151 } |
| 156 | 152 |
| 157 void _contentType1Handler(HttpRequest request, HttpResponse response) { | 153 void _contentType1Handler(HttpRequest request, HttpResponse response) { |
| 158 Expect.equals("text/html", request.headers.contentType.value); | 154 Expect.equals("text/html", request.headers.contentType.value); |
| 159 Expect.equals("text", request.headers.contentType.primaryType); | 155 Expect.equals("text", request.headers.contentType.primaryType); |
| 160 Expect.equals("html", request.headers.contentType.subType); | 156 Expect.equals("html", request.headers.contentType.subType); |
| 161 Expect.equals("utf-8", request.headers.contentType.parameters["charset"]); | 157 Expect.equals("utf-8", request.headers.contentType.parameters["charset"]); |
| 162 | 158 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 void testExpires() { | 511 void testExpires() { |
| 516 TestServerMain testServerMain = new TestServerMain(); | 512 TestServerMain testServerMain = new TestServerMain(); |
| 517 testServerMain.setServerStartedHandler((int port) { | 513 testServerMain.setServerStartedHandler((int port) { |
| 518 int responses = 0; | 514 int responses = 0; |
| 519 HttpClient httpClient = new HttpClient(); | 515 HttpClient httpClient = new HttpClient(); |
| 520 | 516 |
| 521 void processResponse(HttpClientResponse response) { | 517 void processResponse(HttpClientResponse response) { |
| 522 Expect.equals(HttpStatus.OK, response.statusCode); | 518 Expect.equals(HttpStatus.OK, response.statusCode); |
| 523 Expect.equals("Fri, 11 Jun 1999 18:46:53 GMT", | 519 Expect.equals("Fri, 11 Jun 1999 18:46:53 GMT", |
| 524 response.headers["expires"][0]); | 520 response.headers["expires"][0]); |
| 525 Expect.equals( | 521 Expect.equals(new Date(1999, Date.JUN, 11, 18, 46, 53, 0, isUtc: true), |
| 526 new Date.withTimeZone( | 522 response.headers.expires); |
| 527 1999, Date.JUN, 11, 18, 46, 53, 0, new TimeZone.utc()), | |
| 528 response.headers.expires); | |
| 529 responses++; | 523 responses++; |
| 530 if (responses == 2) { | 524 if (responses == 2) { |
| 531 httpClient.shutdown(); | 525 httpClient.shutdown(); |
| 532 testServerMain.shutdown(); | 526 testServerMain.shutdown(); |
| 533 } | 527 } |
| 534 } | 528 } |
| 535 | 529 |
| 536 HttpClientConnection conn1 = httpClient.get("127.0.0.1", port, "/expires1"); | 530 HttpClientConnection conn1 = httpClient.get("127.0.0.1", port, "/expires1"); |
| 537 conn1.onResponse = (HttpClientResponse response) { | 531 conn1.onResponse = (HttpClientResponse response) { |
| 538 processResponse(response); | 532 processResponse(response); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 testReadInto(true); | 596 testReadInto(true); |
| 603 testReadInto(false); | 597 testReadInto(false); |
| 604 testReadShort(true); | 598 testReadShort(true); |
| 605 testReadShort(false); | 599 testReadShort(false); |
| 606 test404(); | 600 test404(); |
| 607 testReasonPhrase(); | 601 testReasonPhrase(); |
| 608 testHost(); | 602 testHost(); |
| 609 testExpires(); | 603 testExpires(); |
| 610 testContentType(); | 604 testContentType(); |
| 611 } | 605 } |
| OLD | NEW |