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

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

Issue 10414076: Support for cookies in the HTTP library (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@google.com Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #source("../../../runtime/bin/input_stream.dart"); 5 #source("../../../runtime/bin/input_stream.dart");
6 #source("../../../runtime/bin/output_stream.dart"); 6 #source("../../../runtime/bin/output_stream.dart");
7 #source("../../../runtime/bin/chunked_stream.dart"); 7 #source("../../../runtime/bin/chunked_stream.dart");
8 #source("../../../runtime/bin/string_stream.dart"); 8 #source("../../../runtime/bin/string_stream.dart");
9 #source("../../../runtime/bin/stream_util.dart"); 9 #source("../../../runtime/bin/stream_util.dart");
10 #source("../../../runtime/bin/http.dart"); 10 #source("../../../runtime/bin/http.dart");
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 headers.set(HttpHeaders.CONTENT_TYPE, "text/plain; charset=utf-8"); 269 headers.set(HttpHeaders.CONTENT_TYPE, "text/plain; charset=utf-8");
270 Expect.equals("text", headers.contentType.primaryType); 270 Expect.equals("text", headers.contentType.primaryType);
271 Expect.equals("plain", headers.contentType.subType); 271 Expect.equals("plain", headers.contentType.subType);
272 Expect.equals("text/plain", headers.contentType.value); 272 Expect.equals("text/plain", headers.contentType.value);
273 headers.removeAll(HttpHeaders.CONTENT_TYPE); 273 headers.removeAll(HttpHeaders.CONTENT_TYPE);
274 Expect.equals("", headers.contentType.primaryType); 274 Expect.equals("", headers.contentType.primaryType);
275 Expect.equals("", headers.contentType.subType); 275 Expect.equals("", headers.contentType.subType);
276 Expect.equals("/", headers.contentType.value); 276 Expect.equals("/", headers.contentType.value);
277 } 277 }
278 278
279 void testCookie() {
280 void checkCookiesEquals(a, b) {
281 Expect.equals(a.name, b.name);
282 Expect.equals(a.value, b.value);
283 Expect.equals(a.expires, b.expires);
284 Expect.equals(a.toString(), b.toString());
285 }
286
287 void checkCookie(cookie, s) {
288 Expect.equals(s, cookie.toString());
289 var c = new _Cookie.fromSetCookieValue(s);
290 checkCookiesEquals(cookie, c);
291 }
292
293 Cookie cookie;
294 cookie = new Cookie("name", "value");
295 Expect.equals("name=value", cookie.toString());
296 TimeZone utc = new TimeZone.utc();
297 Date date = new Date.withTimeZone(2014, Date.JAN, 5, 23, 59, 59, 0, utc);
298 cookie.expires = date;
299 checkCookie(cookie, "name=value"
300 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT");
301 cookie.maxAge = 567;
302 checkCookie(cookie, "name=value"
303 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
304 "; Max-Age=567");
305 cookie.domain = "example.com";
306 checkCookie(cookie, "name=value"
307 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
308 "; Max-Age=567"
309 "; Domain=example.com");
310 cookie.path = "/xxx";
311 checkCookie(cookie, "name=value"
312 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
313 "; Max-Age=567"
314 "; Domain=example.com"
315 "; Path=/xxx");
316 cookie.secure = true;
317 checkCookie(cookie, "name=value"
318 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
319 "; Max-Age=567"
320 "; Domain=example.com"
321 "; Path=/xxx"
322 "; Secure");
323 cookie.httpOnly = true;
324 checkCookie(cookie, "name=value"
325 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
326 "; Max-Age=567"
327 "; Domain=example.com"
328 "; Path=/xxx"
329 "; Secure"
330 "; HttpOnly");
331 cookie.expires = null;
332 checkCookie(cookie, "name=value"
333 "; Max-Age=567"
334 "; Domain=example.com"
335 "; Path=/xxx"
336 "; Secure"
337 "; HttpOnly");
338 cookie.maxAge = null;
339 checkCookie(cookie, "name=value"
340 "; Domain=example.com"
341 "; Path=/xxx"
342 "; Secure"
343 "; HttpOnly");
344 cookie.domain = null;
345 checkCookie(cookie, "name=value"
346 "; Path=/xxx"
347 "; Secure"
348 "; HttpOnly");
349 cookie.path = null;
350 checkCookie(cookie, "name=value"
351 "; Secure"
352 "; HttpOnly");
353 cookie.secure = false;
354 checkCookie(cookie, "name=value"
355 "; HttpOnly");
356 cookie.httpOnly = false;
357 checkCookie(cookie, "name=value");
358 }
359
279 main() { 360 main() {
280 testMultiValue(); 361 testMultiValue();
281 testExpires(); 362 testExpires();
282 testHost(); 363 testHost();
283 testEnumeration(); 364 testEnumeration();
284 testHeaderValue(); 365 testHeaderValue();
285 testContentType(); 366 testContentType();
286 testContentTypeCache(); 367 testContentTypeCache();
368 testCookie();
287 } 369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698