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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_cookie_test.dart
diff --git a/tests/standalone/io/http_cookie_test.dart b/tests/standalone/io/http_cookie_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..edc0bfd89a17404594b3053cbc59285ba832311d
--- /dev/null
+++ b/tests/standalone/io/http_cookie_test.dart
@@ -0,0 +1,66 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+import "dart:async";
+import "dart:io";
+
+void testCookies() {
+ var cookies = [{'abc': 'def'},
+ {'ABC': 'DEF'},
+ {'Abc': 'Def'},
+ {'Abc': 'Def', 'SID': 'sffFSDF4FsdfF56765'}];
+
+ HttpServer.bind("127.0.0.1", 0).then((server) {
+ server.listen((HttpRequest request) {
+ // Collect the cookies in a map.
+ var cookiesMap = {};
+ request.cookies.forEach((c) => cookiesMap[c.name] = c.value);
+ int index = int.parse(request.uri.path.substring(1));
+ Expect.mapEquals(cookies[index], cookiesMap);
+ // Return the same cookies to the client.
+ cookiesMap.forEach((k, v) {
+ request.response.cookies.add(new Cookie(k, v));
+ });
+ request.response.close();
+ });
+
+ int count = 0;
+ HttpClient client = new HttpClient();
+ for (int i = 0; i < cookies.length; i++) {
+ client.get("127.0.0.1", server.port, "/$i")
+ .then((request) {
+ // Send the cookies to the server.
+ cookies[i].forEach((k, v) {
+ request.cookies.add(new Cookie(k, v));
+ });
+ return request.close();
+ })
+ .then((response) {
+ // Expect the same cookies back.
+ var cookiesMap = {};
+ response.cookies.forEach((c) => cookiesMap[c.name] = c.value);
+ Expect.mapEquals(cookies[i], cookiesMap);
+ response.listen(
+ (d) {},
+ onDone: () {
+ if (++count == cookies.length) {
+ client.close();
+ server.close();
+ }
+ });
+ })
+ .catchError((e) {
+ String msg = "Unexpected error $e";
+ var trace = getAttachedStackTrace(e);
+ if (trace != null) msg += "\nStackTrace: $trace";
+ Expect.fail(msg);
+ });
+ }
+ });
+}
+
+void main() {
+ testCookies();
+}
« 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