| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library shelf_io_test; | 5 library shelf_io_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 test('Request is populated correctly', () { | 78 test('Request is populated correctly', () { |
| 79 var path = '/foo/bar?qs=value'; | 79 var path = '/foo/bar?qs=value'; |
| 80 | 80 |
| 81 _scheduleServer((request) { | 81 _scheduleServer((request) { |
| 82 expect(request.contentLength, 0); | 82 expect(request.contentLength, 0); |
| 83 expect(request.method, 'GET'); | 83 expect(request.method, 'GET'); |
| 84 | 84 |
| 85 var expectedUrl = 'http://localhost:$_serverPort$path'; | 85 var expectedUrl = 'http://localhost:$_serverPort$path'; |
| 86 expect(request.requestedUri, Uri.parse(expectedUrl)); | 86 expect(request.requestedUri, Uri.parse(expectedUrl)); |
| 87 | 87 |
| 88 expect(request.url.path, '/foo/bar'); | 88 expect(request.url.path, 'foo/bar'); |
| 89 expect(request.url.pathSegments, ['foo', 'bar']); | 89 expect(request.url.pathSegments, ['foo', 'bar']); |
| 90 expect(request.protocolVersion, '1.1'); | 90 expect(request.protocolVersion, '1.1'); |
| 91 expect(request.url.query, 'qs=value'); | 91 expect(request.url.query, 'qs=value'); |
| 92 expect(request.scriptName, ''); | 92 expect(request.handlerPath, '/'); |
| 93 | 93 |
| 94 return syncHandler(request); | 94 return syncHandler(request); |
| 95 }); | 95 }); |
| 96 | 96 |
| 97 return schedule(() => http.get('http://localhost:$_serverPort$path')).then( | 97 return schedule(() => http.get('http://localhost:$_serverPort$path')).then( |
| 98 (response) { | 98 (response) { |
| 99 expect(response.statusCode, HttpStatus.OK); | 99 expect(response.statusCode, HttpStatus.OK); |
| 100 expect(response.body, 'Hello from /foo/bar'); | 100 expect(response.body, 'Hello from /foo/bar'); |
| 101 }); | 101 }); |
| 102 }); | 102 }); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 return schedule(() { | 358 return schedule(() { |
| 359 var request = | 359 var request = |
| 360 new http.Request('POST', Uri.parse('http://localhost:$_serverPort/')); | 360 new http.Request('POST', Uri.parse('http://localhost:$_serverPort/')); |
| 361 | 361 |
| 362 if (headers != null) request.headers.addAll(headers); | 362 if (headers != null) request.headers.addAll(headers); |
| 363 if (body != null) request.body = body; | 363 if (body != null) request.body = body; |
| 364 | 364 |
| 365 return request.send(); | 365 return request.send(); |
| 366 }); | 366 }); |
| 367 } | 367 } |
| OLD | NEW |