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

Side by Side Diff: runtime/bin/http.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 second round of comments 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
« no previous file with comments | « no previous file | runtime/bin/http_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * HTTP status codes. 6 * HTTP status codes.
7 */ 7 */
8 interface HttpStatus { 8 interface HttpStatus {
9 static final int CONTINUE = 100; 9 static final int CONTINUE = 100;
10 static final int SWITCHING_PROTOCOLS = 101; 10 static final int SWITCHING_PROTOCOLS = 101;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 void removeAll(String name); 270 void removeAll(String name);
271 271
272 /** 272 /**
273 * Enumerate the headers applying the function [f] to each 273 * Enumerate the headers applying the function [f] to each
274 * header. The header name passed in [name] will be all lower 274 * header. The header name passed in [name] will be all lower
275 * case. 275 * case.
276 */ 276 */
277 void forEach(void f(String name, List<String> values)); 277 void forEach(void f(String name, List<String> values));
278 278
279 /** 279 /**
280 * Disable folding for the header named [name] when sending the HTTP
281 * header. By default, multiple header values are folded into a
282 * single header line by separating the values with commas. The
283 * Set-Cookie header has folding disabled by default.
284 */
285 void noFolding(String name);
286
287 /**
280 * Gets and sets the date. The value of this property will 288 * Gets and sets the date. The value of this property will
281 * reflect the "Date" header 289 * reflect the "Date" header
282 */ 290 */
283 Date date; 291 Date date;
284 292
285 /** 293 /**
286 * Gets and sets the expiry date. The value of this property will 294 * Gets and sets the expiry date. The value of this property will
287 * reflect the "Expires" header 295 * reflect the "Expires" header
288 */ 296 */
289 Date expires; 297 Date expires;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 * Gets the map of parameters. 369 * Gets the map of parameters.
362 */ 370 */
363 Map<String, String> get parameters(); 371 Map<String, String> get parameters();
364 372
365 /** 373 /**
366 * Returns the formatted string representation in the form: 374 * Returns the formatted string representation in the form:
367 * 375 *
368 * value; parameter1=value1; parameter2=value2 376 * value; parameter1=value1; parameter2=value2
369 */ 377 */
370 String toString(); 378 String toString();
371
372 } 379 }
373 380
374 381
375 /** 382 /**
376 * Representation of a content type. 383 * Representation of a content type.
377 */ 384 */
378 interface ContentType extends HeaderValue default _ContentType { 385 interface ContentType extends HeaderValue default _ContentType {
379 /** 386 /**
380 * Creates a new content type object setting the primary type and 387 * Creates a new content type object setting the primary type and
381 * sub type. If either is not passed their values will be the empty 388 * sub type. If either is not passed their values will be the empty
(...skipping 30 matching lines...) Expand all
412 String subType; 419 String subType;
413 420
414 /** 421 /**
415 * Gets and sets the character set. 422 * Gets and sets the character set.
416 */ 423 */
417 String charset; 424 String charset;
418 } 425 }
419 426
420 427
421 /** 428 /**
429 * Representation of a cookie. For cookies received by the server as
430 * Cookie header values only [:name:] and [:value:] fields will be
431 * set. When building a cookie for the Set-Cookie header in the server
432 * and when receiving cookies in the client as Set-Cookie headers all
433 * fields can be used.
434 */
435 interface Cookie default _Cookie {
436 /**
437 * Creates a new cookie optionally setting the name and value.
438 */
439 Cookie([String name, String value]);
440
441 /**
442 * Creates a new cookie by parsing a header value from a Set-Cookie
443 * header.
444 */
445 Cookie.fromSetCookieValue(String value);
446
447 /**
448 * Gets and sets the name.
449 */
450 String name;
451
452 /**
453 * Gets and sets the value.
454 */
455 String value;
456
457 /**
458 * Gets and sets the expiry date.
459 */
460 Date expires;
461
462 /**
463 * Gets and sets the max age. A value of [:0:] means delete cookie
464 * now.
465 */
466 int maxAge;
467
468 /**
469 * Gets and sets the domain.
470 */
471 String domain;
472
473 /**
474 * Gets and sets the path.
475 */
476 String path;
477
478 /**
479 * Gets and sets whether this cookie is secure.
480 */
481 bool secure;
482
483 /**
484 * Gets and sets whether this cookie is HTTP only.
485 */
486 bool httpOnly;
487
488 /**
489 * Returns the formatted string representation of the cookie. The
490 * string representation can be used for for setting the Cookie or
491 * Set-Cookie headers
492 */
493 String toString();
494 }
495
496
497 /**
422 * Http request delivered to the HTTP server callback. 498 * Http request delivered to the HTTP server callback.
423 */ 499 */
424 interface HttpRequest default _HttpRequest { 500 interface HttpRequest default _HttpRequest {
425 /** 501 /**
426 * Returns the content length of the request body. If the size of 502 * Returns the content length of the request body. If the size of
427 * the request body is not known in advance this -1. 503 * the request body is not known in advance this -1.
428 */ 504 */
429 int get contentLength(); 505 int get contentLength();
430 506
431 /** 507 /**
(...skipping 25 matching lines...) Expand all
457 * Returns the parsed query string. 533 * Returns the parsed query string.
458 */ 534 */
459 Map<String, String> get queryParameters(); 535 Map<String, String> get queryParameters();
460 536
461 /** 537 /**
462 * Returns the request headers. 538 * Returns the request headers.
463 */ 539 */
464 HttpHeaders get headers(); 540 HttpHeaders get headers();
465 541
466 /** 542 /**
543 * Returns the cookies in the request (from the Cookie header).
544 */
545 List<Cookie> get cookies();
546
547 /**
467 * Returns the input stream for the request. This is used to read 548 * Returns the input stream for the request. This is used to read
468 * the request data. 549 * the request data.
469 */ 550 */
470 InputStream get inputStream(); 551 InputStream get inputStream();
471 552
472 /** 553 /**
473 * Returns the HTTP protocol version used in the request. This will 554 * Returns the HTTP protocol version used in the request. This will
474 * be "1.0" or "1.1". 555 * be "1.0" or "1.1".
475 */ 556 */
476 String get protocolVersion(); 557 String get protocolVersion();
(...skipping 30 matching lines...) Expand all
507 * request. 588 * request.
508 */ 589 */
509 bool persistentConnection; 590 bool persistentConnection;
510 591
511 /** 592 /**
512 * Returns the response headers. 593 * Returns the response headers.
513 */ 594 */
514 HttpHeaders get headers(); 595 HttpHeaders get headers();
515 596
516 /** 597 /**
598 * Cookies to set in the client (in the Set-Cookie header).
599 */
600 List<Cookie> get cookies();
601
602 /**
517 * Returns the output stream for the response. This is used to write 603 * Returns the output stream for the response. This is used to write
518 * the response data. When all response data has been written close 604 * the response data. When all response data has been written close
519 * the stream to indicate the end of the response. 605 * the stream to indicate the end of the response.
520 * 606 *
521 * When this is accessed for the first time the response header is 607 * When this is accessed for the first time the response header is
522 * send. Calling any methods that will change the header after 608 * send. Calling any methods that will change the header after
523 * having retrieved the output stream will throw an exception. 609 * having retrieved the output stream will throw an exception.
524 */ 610 */
525 OutputStream get outputStream(); 611 OutputStream get outputStream();
526 612
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 * which is also the default. 763 * which is also the default.
678 */ 764 */
679 int contentLength; 765 int contentLength;
680 766
681 /** 767 /**
682 * Returns the request headers. 768 * Returns the request headers.
683 */ 769 */
684 HttpHeaders get headers(); 770 HttpHeaders get headers();
685 771
686 /** 772 /**
773 * Cookies to present to the server (in the Cookie header).
774 */
775 List<Cookie> get cookies();
776
777 /**
687 * Returns the output stream for the request. This is used to write 778 * Returns the output stream for the request. This is used to write
688 * the request data. When all request data has been written close 779 * the request data. When all request data has been written close
689 * the stream to indicate the end of the request. 780 * the stream to indicate the end of the request.
690 * 781 *
691 * When this is accessed for the first time the request header is 782 * When this is accessed for the first time the request header is
692 * send. Calling any methods that will change the header after 783 * send. Calling any methods that will change the header after
693 * having retrieved the output stream will throw an exception. 784 * having retrieved the output stream will throw an exception.
694 */ 785 */
695 OutputStream get outputStream(); 786 OutputStream get outputStream();
696 } 787 }
(...skipping 26 matching lines...) Expand all
723 * [:HttpStatus.TEMPORARY_REDIRECT:]. 814 * [:HttpStatus.TEMPORARY_REDIRECT:].
724 */ 815 */
725 bool get isRedirect(); 816 bool get isRedirect();
726 817
727 /** 818 /**
728 * Returns the response headers. 819 * Returns the response headers.
729 */ 820 */
730 HttpHeaders get headers(); 821 HttpHeaders get headers();
731 822
732 /** 823 /**
824 * Cookies set by the server (from the Set-Cookie header).
825 */
826 List<Cookie> get cookies();
827
828 /**
733 * Returns the input stream for the response. This is used to read 829 * Returns the input stream for the response. This is used to read
734 * the response data. 830 * the response data.
735 */ 831 */
736 InputStream get inputStream(); 832 InputStream get inputStream();
737 } 833 }
738 834
739 835
740 /** 836 /**
741 * Redirect information. 837 * Redirect information.
742 */ 838 */
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 class RedirectLimitExceededException extends RedirectException { 884 class RedirectLimitExceededException extends RedirectException {
789 const RedirectLimitExceededException(List<RedirectInfo> redirects) 885 const RedirectLimitExceededException(List<RedirectInfo> redirects)
790 : super("Redirect limit exceeded", redirects); 886 : super("Redirect limit exceeded", redirects);
791 } 887 }
792 888
793 889
794 class RedirectLoopException extends RedirectException { 890 class RedirectLoopException extends RedirectException {
795 const RedirectLoopException(List<RedirectInfo> redirects) 891 const RedirectLoopException(List<RedirectInfo> redirects)
796 : super("Redirect loop detected", redirects); 892 : super("Redirect loop detected", redirects);
797 } 893 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698