OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "dart:async"; | 6 import "dart:async"; |
7 import "dart:io"; | 7 import "dart:io"; |
8 | 8 |
9 void testCookies() { | 9 void testCookies() { |
10 var cookies = [{'abc': 'def'}, | 10 var cookies = [{'abc': 'def'}, |
(...skipping 24 matching lines...) Expand all Loading... |
35 cookies[i].forEach((k, v) { | 35 cookies[i].forEach((k, v) { |
36 request.cookies.add(new Cookie(k, v)); | 36 request.cookies.add(new Cookie(k, v)); |
37 }); | 37 }); |
38 return request.close(); | 38 return request.close(); |
39 }) | 39 }) |
40 .then((response) { | 40 .then((response) { |
41 // Expect the same cookies back. | 41 // Expect the same cookies back. |
42 var cookiesMap = {}; | 42 var cookiesMap = {}; |
43 response.cookies.forEach((c) => cookiesMap[c.name] = c.value); | 43 response.cookies.forEach((c) => cookiesMap[c.name] = c.value); |
44 Expect.mapEquals(cookies[i], cookiesMap); | 44 Expect.mapEquals(cookies[i], cookiesMap); |
| 45 response.cookies.forEach((c) => Expect.isTrue(c.httpOnly)); |
45 response.listen( | 46 response.listen( |
46 (d) {}, | 47 (d) {}, |
47 onDone: () { | 48 onDone: () { |
48 if (++count == cookies.length) { | 49 if (++count == cookies.length) { |
49 client.close(); | 50 client.close(); |
50 server.close(); | 51 server.close(); |
51 } | 52 } |
52 }); | 53 }); |
53 }) | 54 }) |
54 .catchError((e, trace) { | 55 .catchError((e, trace) { |
55 String msg = "Unexpected error $e"; | 56 String msg = "Unexpected error $e"; |
56 if (trace != null) msg += "\nStackTrace: $trace"; | 57 if (trace != null) msg += "\nStackTrace: $trace"; |
57 Expect.fail(msg); | 58 Expect.fail(msg); |
58 }); | 59 }); |
59 } | 60 } |
60 }); | 61 }); |
61 } | 62 } |
62 | 63 |
63 void main() { | 64 void main() { |
64 testCookies(); | 65 testCookies(); |
65 } | 66 } |
OLD | NEW |