| 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:async'; | 10 import 'dart:async'; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 Expect.equals(1, request.headers["Host"].length); | 111 Expect.equals(1, request.headers["Host"].length); |
| 112 Expect.equals("www.dartlang.org:1234", request.headers["Host"][0]); | 112 Expect.equals("www.dartlang.org:1234", request.headers["Host"][0]); |
| 113 Expect.equals("www.dartlang.org", request.headers.host); | 113 Expect.equals("www.dartlang.org", request.headers.host); |
| 114 Expect.equals(1234, request.headers.port); | 114 Expect.equals(1234, request.headers.port); |
| 115 response.statusCode = HttpStatus.OK; | 115 response.statusCode = HttpStatus.OK; |
| 116 response.outputStream.close(); | 116 response.outputStream.close(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Set the "Expires" header using the expires property. | 119 // Set the "Expires" header using the expires property. |
| 120 void _expires1Handler(HttpRequest request, HttpResponse response) { | 120 void _expires1Handler(HttpRequest request, HttpResponse response) { |
| 121 Date date = new Date.utc(1999, Date.JUN, 11, 18, 46, 53, 0); | 121 DateTime date = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0); |
| 122 response.headers.expires = date; | 122 response.headers.expires = date; |
| 123 Expect.equals(date, response.headers.expires); | 123 Expect.equals(date, response.headers.expires); |
| 124 response.outputStream.close(); | 124 response.outputStream.close(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Set the "Expires" header. | 127 // Set the "Expires" header. |
| 128 void _expires2Handler(HttpRequest request, HttpResponse response) { | 128 void _expires2Handler(HttpRequest request, HttpResponse response) { |
| 129 response.headers.set("Expires", "Fri, 11 Jun 1999 18:46:53 GMT"); | 129 response.headers.set("Expires", "Fri, 11 Jun 1999 18:46:53 GMT"); |
| 130 Date date = new Date.utc(1999, Date.JUN, 11, 18, 46, 53, 0); | 130 DateTime date = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0); |
| 131 Expect.equals(date, response.headers.expires); | 131 Expect.equals(date, response.headers.expires); |
| 132 response.outputStream.close(); | 132 response.outputStream.close(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void _contentType1Handler(HttpRequest request, HttpResponse response) { | 135 void _contentType1Handler(HttpRequest request, HttpResponse response) { |
| 136 Expect.equals("text/html", request.headers.contentType.value); | 136 Expect.equals("text/html", request.headers.contentType.value); |
| 137 Expect.equals("text", request.headers.contentType.primaryType); | 137 Expect.equals("text", request.headers.contentType.primaryType); |
| 138 Expect.equals("html", request.headers.contentType.subType); | 138 Expect.equals("html", request.headers.contentType.subType); |
| 139 Expect.equals("utf-8", request.headers.contentType.parameters["charset"]); | 139 Expect.equals("utf-8", request.headers.contentType.parameters["charset"]); |
| 140 | 140 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 153 response.headers.set(HttpHeaders.CONTENT_TYPE, | 153 response.headers.set(HttpHeaders.CONTENT_TYPE, |
| 154 "text/html; charset = utf-8"); | 154 "text/html; charset = utf-8"); |
| 155 response.outputStream.close(); | 155 response.outputStream.close(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void _cookie1Handler(HttpRequest request, HttpResponse response) { | 158 void _cookie1Handler(HttpRequest request, HttpResponse response) { |
| 159 // No cookies passed with this request. | 159 // No cookies passed with this request. |
| 160 Expect.equals(0, request.cookies.length); | 160 Expect.equals(0, request.cookies.length); |
| 161 | 161 |
| 162 Cookie cookie1 = new Cookie("name1", "value1"); | 162 Cookie cookie1 = new Cookie("name1", "value1"); |
| 163 Date date = new Date.utc(2014, Date.JAN, 5, 23, 59, 59, 0); | 163 DateTime date = new DateTime.utc(2014, DateTime.JAN, 5, 23, 59, 59, 0); |
| 164 cookie1.expires = date; | 164 cookie1.expires = date; |
| 165 cookie1.domain = "www.example.com"; | 165 cookie1.domain = "www.example.com"; |
| 166 cookie1.httpOnly = true; | 166 cookie1.httpOnly = true; |
| 167 response.cookies.add(cookie1); | 167 response.cookies.add(cookie1); |
| 168 Cookie cookie2 = new Cookie("name2", "value2"); | 168 Cookie cookie2 = new Cookie("name2", "value2"); |
| 169 cookie2.maxAge = 100; | 169 cookie2.maxAge = 100; |
| 170 cookie2.domain = ".example.com"; | 170 cookie2.domain = ".example.com"; |
| 171 cookie2.path = "/shop"; | 171 cookie2.path = "/shop"; |
| 172 response.cookies.add(cookie2); | 172 response.cookies.add(cookie2); |
| 173 response.outputStream.close(); | 173 response.outputStream.close(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 Completer completer = new Completer(); | 304 Completer completer = new Completer(); |
| 305 TestServerMain testServerMain = new TestServerMain(); | 305 TestServerMain testServerMain = new TestServerMain(); |
| 306 testServerMain.setServerStartedHandler((int port) { | 306 testServerMain.setServerStartedHandler((int port) { |
| 307 int responses = 0; | 307 int responses = 0; |
| 308 HttpClient httpClient = new HttpClient(); | 308 HttpClient httpClient = new HttpClient(); |
| 309 | 309 |
| 310 void processResponse(HttpClientResponse response) { | 310 void processResponse(HttpClientResponse response) { |
| 311 Expect.equals(HttpStatus.OK, response.statusCode); | 311 Expect.equals(HttpStatus.OK, response.statusCode); |
| 312 Expect.equals("Fri, 11 Jun 1999 18:46:53 GMT", | 312 Expect.equals("Fri, 11 Jun 1999 18:46:53 GMT", |
| 313 response.headers["expires"][0]); | 313 response.headers["expires"][0]); |
| 314 Expect.equals(new Date.utc(1999, Date.JUN, 11, 18, 46, 53, 0), | 314 Expect.equals(new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0), |
| 315 response.headers.expires); | 315 response.headers.expires); |
| 316 response.inputStream.onData = response.inputStream.read; | 316 response.inputStream.onData = response.inputStream.read; |
| 317 response.inputStream.onClosed = () { | 317 response.inputStream.onClosed = () { |
| 318 responses++; | 318 responses++; |
| 319 if (responses == 2) { | 319 if (responses == 2) { |
| 320 httpClient.shutdown(); | 320 httpClient.shutdown(); |
| 321 testServerMain.shutdown(); | 321 testServerMain.shutdown(); |
| 322 completer.complete(true); | 322 completer.complete(true); |
| 323 } | 323 } |
| 324 }; | 324 }; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 int responses = 0; | 398 int responses = 0; |
| 399 HttpClient httpClient = new HttpClient(); | 399 HttpClient httpClient = new HttpClient(); |
| 400 | 400 |
| 401 HttpClientConnection conn1 = | 401 HttpClientConnection conn1 = |
| 402 httpClient.get("127.0.0.1", port, "/cookie1"); | 402 httpClient.get("127.0.0.1", port, "/cookie1"); |
| 403 conn1.onResponse = (HttpClientResponse response) { | 403 conn1.onResponse = (HttpClientResponse response) { |
| 404 Expect.equals(2, response.cookies.length); | 404 Expect.equals(2, response.cookies.length); |
| 405 response.cookies.forEach((cookie) { | 405 response.cookies.forEach((cookie) { |
| 406 if (cookie.name == "name1") { | 406 if (cookie.name == "name1") { |
| 407 Expect.equals("value1", cookie.value); | 407 Expect.equals("value1", cookie.value); |
| 408 Date date = new Date.utc(2014, Date.JAN, 5, 23, 59, 59, 0); | 408 DateTime date = new DateTime.utc(2014, DateTime.JAN, 5, 23, 59, 59, 0)
; |
| 409 Expect.equals(date, cookie.expires); | 409 Expect.equals(date, cookie.expires); |
| 410 Expect.equals("www.example.com", cookie.domain); | 410 Expect.equals("www.example.com", cookie.domain); |
| 411 Expect.isTrue(cookie.httpOnly); | 411 Expect.isTrue(cookie.httpOnly); |
| 412 } else if (cookie.name == "name2") { | 412 } else if (cookie.name == "name2") { |
| 413 Expect.equals("value2", cookie.value); | 413 Expect.equals("value2", cookie.value); |
| 414 Expect.equals(100, cookie.maxAge); | 414 Expect.equals(100, cookie.maxAge); |
| 415 Expect.equals(".example.com", cookie.domain); | 415 Expect.equals(".example.com", cookie.domain); |
| 416 Expect.equals("/shop", cookie.path); | 416 Expect.equals("/shop", cookie.path); |
| 417 } else { | 417 } else { |
| 418 Expect.fail("Unexpected cookie"); | 418 Expect.fail("Unexpected cookie"); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 return testCookies().then((_) { | 475 return testCookies().then((_) { |
| 476 print('testFlush()'); | 476 print('testFlush()'); |
| 477 return testFlush(); | 477 return testFlush(); |
| 478 }); | 478 }); |
| 479 }); | 479 }); |
| 480 }); | 480 }); |
| 481 }).then((_) { | 481 }).then((_) { |
| 482 print('done'); | 482 print('done'); |
| 483 }); | 483 }); |
| 484 } | 484 } |
| OLD | NEW |