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

Side by Side Diff: tests/standalone/io/http_requested_uri_test.dart

Issue 125743002: Add HttpRequest::requestedUri. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 import "package:expect/expect.dart";
6 import "package:async_helper/async_helper.dart";
7 import "dart:async";
8 import "dart:io";
9
10 const PATH = '/path?a=b#c';
11
12 void test(String expected, Map headers) {
13 asyncStart();
14 HttpServer.bind("127.0.0.1", 0).then((server) {
15 expected = expected.replaceAll('%PORT', server.port.toString());
16 server.listen((request) {
17 Expect.equals("$expected$PATH",
18 request.requestedUri.toString());
19 request.response.close();
20 });
21 HttpClient client = new HttpClient();
22 client.get("localhost", server.port, PATH)
23 .then((request) {
24 for (var v in headers.keys) {
25 if (headers[v] != null) {
26 request.headers.set(v, headers[v]);
27 } else {
28 request.headers.removeAll(v);
29 }
30 }
31 return request.close();
32 })
33 .then((response) => response.drain())
34 .then((_) {
35 server.close();
36 asyncEnd();
37 });
38 });
39 }
40
41
42 void main() {
43 test('http://localhost:%PORT', {});
44 test('https://localhost:%PORT', {'x-forwarded-proto': 'https'});
45 test('ws://localhost:%PORT', {'x-forwarded-proto': 'ws'});
46 test('http://my-host:321', {'x-forwarded-host': 'my-host:321'});
47 test('http://127.0.0.1:%PORT', {'host': null});
48 }
49
OLDNEW
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698