| 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')) | 97 return schedule(() => http.get('http://localhost:$_serverPort$path')) |
| 98 .then((response) { | 98 .then((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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 364 |
| 365 var request = new http.Request('POST', | 365 var request = new http.Request('POST', |
| 366 Uri.parse('http://localhost:$_serverPort/')); | 366 Uri.parse('http://localhost:$_serverPort/')); |
| 367 | 367 |
| 368 if (headers != null) request.headers.addAll(headers); | 368 if (headers != null) request.headers.addAll(headers); |
| 369 if (body != null) request.body = body; | 369 if (body != null) request.body = body; |
| 370 | 370 |
| 371 return request.send(); | 371 return request.send(); |
| 372 }); | 372 }); |
| 373 } | 373 } |
| OLD | NEW |