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

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

Issue 16256012: Don't change the case of cookie names and values (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed warning found by analyzer Created 7 years, 6 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_headers.dart ('k') | tests/standalone/io/http_headers_test.dart » ('j') | 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 "dart:async";
7 import "dart:io";
8
9 void testCookies() {
10 var cookies = [{'abc': 'def'},
11 {'ABC': 'DEF'},
12 {'Abc': 'Def'},
13 {'Abc': 'Def', 'SID': 'sffFSDF4FsdfF56765'}];
14
15 HttpServer.bind("127.0.0.1", 0).then((server) {
16 server.listen((HttpRequest request) {
17 // Collect the cookies in a map.
18 var cookiesMap = {};
19 request.cookies.forEach((c) => cookiesMap[c.name] = c.value);
20 int index = int.parse(request.uri.path.substring(1));
21 Expect.mapEquals(cookies[index], cookiesMap);
22 // Return the same cookies to the client.
23 cookiesMap.forEach((k, v) {
24 request.response.cookies.add(new Cookie(k, v));
25 });
26 request.response.close();
27 });
28
29 int count = 0;
30 HttpClient client = new HttpClient();
31 for (int i = 0; i < cookies.length; i++) {
32 client.get("127.0.0.1", server.port, "/$i")
33 .then((request) {
34 // Send the cookies to the server.
35 cookies[i].forEach((k, v) {
36 request.cookies.add(new Cookie(k, v));
37 });
38 return request.close();
39 })
40 .then((response) {
41 // Expect the same cookies back.
42 var cookiesMap = {};
43 response.cookies.forEach((c) => cookiesMap[c.name] = c.value);
44 Expect.mapEquals(cookies[i], cookiesMap);
45 response.listen(
46 (d) {},
47 onDone: () {
48 if (++count == cookies.length) {
49 client.close();
50 server.close();
51 }
52 });
53 })
54 .catchError((e) {
55 String msg = "Unexpected error $e";
56 var trace = getAttachedStackTrace(e);
57 if (trace != null) msg += "\nStackTrace: $trace";
58 Expect.fail(msg);
59 });
60 }
61 });
62 }
63
64 void main() {
65 testCookies();
66 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_headers.dart ('k') | tests/standalone/io/http_headers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698