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

Side by Side Diff: runtime/bin/http.dart

Issue 10872033: Change getters syntax in dart:io library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | « runtime/bin/file_impl.dart ('k') | 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 /** 98 /**
99 * Stop server listening. 99 * Stop server listening.
100 */ 100 */
101 void close(); 101 void close();
102 102
103 /** 103 /**
104 * Returns the port that the server is listening on. This can be 104 * Returns the port that the server is listening on. This can be
105 * used to get the actual port used when a value of 0 for [port] is 105 * used to get the actual port used when a value of 0 for [port] is
106 * specified in the [listen] call. 106 * specified in the [listen] call.
107 */ 107 */
108 int get port(); 108 int get port;
109 109
110 /** 110 /**
111 * Sets the error handler that is called when a connection error occurs. 111 * Sets the error handler that is called when a connection error occurs.
112 */ 112 */
113 void set onError(void callback(e)); 113 void set onError(void callback(e));
114 } 114 }
115 115
116 116
117 /** 117 /**
118 * Access to the HTTP headers for requests and responses. In some 118 * Access to the HTTP headers for requests and responses. In some
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 HeaderValue.fromString(String value); 367 HeaderValue.fromString(String value);
368 368
369 /** 369 /**
370 * Gets and sets the header value. 370 * Gets and sets the header value.
371 */ 371 */
372 String value; 372 String value;
373 373
374 /** 374 /**
375 * Gets the map of parameters. 375 * Gets the map of parameters.
376 */ 376 */
377 Map<String, String> get parameters(); 377 Map<String, String> get parameters;
378 378
379 /** 379 /**
380 * Returns the formatted string representation in the form: 380 * Returns the formatted string representation in the form:
381 * 381 *
382 * value; parameter1=value1; parameter2=value2 382 * value; parameter1=value1; parameter2=value2
383 */ 383 */
384 String toString(); 384 String toString();
385 } 385 }
386 386
387 387
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 501
502 502
503 /** 503 /**
504 * Http request delivered to the HTTP server callback. 504 * Http request delivered to the HTTP server callback.
505 */ 505 */
506 interface HttpRequest default _HttpRequest { 506 interface HttpRequest default _HttpRequest {
507 /** 507 /**
508 * Returns the content length of the request body. If the size of 508 * Returns the content length of the request body. If the size of
509 * the request body is not known in advance this -1. 509 * the request body is not known in advance this -1.
510 */ 510 */
511 int get contentLength(); 511 int get contentLength;
512 512
513 /** 513 /**
514 * Returns the persistent connection state signaled by the client. 514 * Returns the persistent connection state signaled by the client.
515 */ 515 */
516 bool get persistentConnection(); 516 bool get persistentConnection;
517 517
518 /** 518 /**
519 * Returns the method for the request. 519 * Returns the method for the request.
520 */ 520 */
521 String get method(); 521 String get method;
522 522
523 /** 523 /**
524 * Returns the URI for the request. 524 * Returns the URI for the request.
525 */ 525 */
526 String get uri(); 526 String get uri;
527 527
528 /** 528 /**
529 * Returns the path part of the URI. 529 * Returns the path part of the URI.
530 */ 530 */
531 String get path(); 531 String get path;
532 532
533 /** 533 /**
534 * Returns the query string. 534 * Returns the query string.
535 */ 535 */
536 String get queryString(); 536 String get queryString;
537 537
538 /** 538 /**
539 * Returns the parsed query string. 539 * Returns the parsed query string.
540 */ 540 */
541 Map<String, String> get queryParameters(); 541 Map<String, String> get queryParameters;
542 542
543 /** 543 /**
544 * Returns the request headers. 544 * Returns the request headers.
545 */ 545 */
546 HttpHeaders get headers(); 546 HttpHeaders get headers;
547 547
548 /** 548 /**
549 * Returns the cookies in the request (from the Cookie header). 549 * Returns the cookies in the request (from the Cookie header).
550 */ 550 */
551 List<Cookie> get cookies(); 551 List<Cookie> get cookies;
552 552
553 /** 553 /**
554 * Returns the input stream for the request. This is used to read 554 * Returns the input stream for the request. This is used to read
555 * the request data. 555 * the request data.
556 */ 556 */
557 InputStream get inputStream(); 557 InputStream get inputStream;
558 558
559 /** 559 /**
560 * Returns the HTTP protocol version used in the request. This will 560 * Returns the HTTP protocol version used in the request. This will
561 * be "1.0" or "1.1". 561 * be "1.0" or "1.1".
562 */ 562 */
563 String get protocolVersion(); 563 String get protocolVersion;
564 564
565 /** 565 /**
566 * Get information about the client connection. Returns [null] if the socket 566 * Get information about the client connection. Returns [null] if the socket
567 * isn't available. 567 * isn't available.
568 */ 568 */
569 HttpConnectionInfo get connectionInfo(); 569 HttpConnectionInfo get connectionInfo;
570 } 570 }
571 571
572 572
573 /** 573 /**
574 * HTTP response to be send back to the client. 574 * HTTP response to be send back to the client.
575 */ 575 */
576 interface HttpResponse default _HttpResponse { 576 interface HttpResponse default _HttpResponse {
577 /** 577 /**
578 * Gets and sets the content length of the response. If the size of 578 * Gets and sets the content length of the response. If the size of
579 * the response is not known in advance set the content length to 579 * the response is not known in advance set the content length to
(...skipping 17 matching lines...) Expand all
597 /** 597 /**
598 * Gets and sets the persistent connection state. The initial value 598 * Gets and sets the persistent connection state. The initial value
599 * of this property is the persistent connection state from the 599 * of this property is the persistent connection state from the
600 * request. 600 * request.
601 */ 601 */
602 bool persistentConnection; 602 bool persistentConnection;
603 603
604 /** 604 /**
605 * Returns the response headers. 605 * Returns the response headers.
606 */ 606 */
607 HttpHeaders get headers(); 607 HttpHeaders get headers;
608 608
609 /** 609 /**
610 * Cookies to set in the client (in the Set-Cookie header). 610 * Cookies to set in the client (in the Set-Cookie header).
611 */ 611 */
612 List<Cookie> get cookies(); 612 List<Cookie> get cookies;
613 613
614 /** 614 /**
615 * Returns the output stream for the response. This is used to write 615 * Returns the output stream for the response. This is used to write
616 * the response data. When all response data has been written close 616 * the response data. When all response data has been written close
617 * the stream to indicate the end of the response. 617 * the stream to indicate the end of the response.
618 * 618 *
619 * When this is accessed for the first time the response header is 619 * When this is accessed for the first time the response header is
620 * send. Calling any methods that will change the header after 620 * send. Calling any methods that will change the header after
621 * having retrieved the output stream will throw an exception. 621 * having retrieved the output stream will throw an exception.
622 */ 622 */
623 OutputStream get outputStream(); 623 OutputStream get outputStream;
624 624
625 /** 625 /**
626 * Detach the underlying socket from the HTTP server. When the 626 * Detach the underlying socket from the HTTP server. When the
627 * socket is detached the HTTP server will no longer perform any 627 * socket is detached the HTTP server will no longer perform any
628 * operations on it. 628 * operations on it.
629 * 629 *
630 * This is normally used when a HTTP upgrade request is received 630 * This is normally used when a HTTP upgrade request is received
631 * and the communication should continue with a different protocol. 631 * and the communication should continue with a different protocol.
632 */ 632 */
633 DetachedSocket detachSocket(); 633 DetachedSocket detachSocket();
634 634
635 /** 635 /**
636 * Get information about the client connection. Returns [null] if the socket 636 * Get information about the client connection. Returns [null] if the socket
637 * isn't available. 637 * isn't available.
638 */ 638 */
639 HttpConnectionInfo get connectionInfo(); 639 HttpConnectionInfo get connectionInfo;
640 } 640 }
641 641
642 642
643 /** 643 /**
644 * HTTP client factory. The [HttpClient] handles all the sockets associated 644 * HTTP client factory. The [HttpClient] handles all the sockets associated
645 * with the [HttpClientConnection]s and when the endpoint supports it, it will 645 * with the [HttpClientConnection]s and when the endpoint supports it, it will
646 * try to reuse opened sockets for several requests to support HTTP 1.1 646 * try to reuse opened sockets for several requests to support HTTP 1.1
647 * persistent connections. This means that sockets will be kept open for some 647 * persistent connections. This means that sockets will be kept open for some
648 * time after a requests have completed, unless HTTP procedures indicate that it 648 * time after a requests have completed, unless HTTP procedures indicate that it
649 * must be closed as part of completing the request. Use [:HttpClient.shutdown:] 649 * must be closed as part of completing the request. Use [:HttpClient.shutdown:]
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 * Set this property to the maximum number of redirects to follow 747 * Set this property to the maximum number of redirects to follow
748 * when [followRedirects] is [:true:]. If this number is exceeded the 748 * when [followRedirects] is [:true:]. If this number is exceeded the
749 * [onError] callback will be called with a [RedirectLimitExceeded] 749 * [onError] callback will be called with a [RedirectLimitExceeded]
750 * exception. The default value is 5. 750 * exception. The default value is 5.
751 */ 751 */
752 int maxRedirects; 752 int maxRedirects;
753 753
754 /** 754 /**
755 * Returns the series of redirects this connection has been through. 755 * Returns the series of redirects this connection has been through.
756 */ 756 */
757 List<RedirectInfo> get redirects(); 757 List<RedirectInfo> get redirects;
758 758
759 /** 759 /**
760 * Redirect this connection to a new URL. The default value for 760 * Redirect this connection to a new URL. The default value for
761 * [method] is the method for the current request. The default value 761 * [method] is the method for the current request. The default value
762 * for [url] is the value of the [:HttpStatus.LOCATION:] header of 762 * for [url] is the value of the [:HttpStatus.LOCATION:] header of
763 * the current response. All body data must have been read from the 763 * the current response. All body data must have been read from the
764 * current response before calling [redirect]. 764 * current response before calling [redirect].
765 */ 765 */
766 void redirect([String method, Uri url]); 766 void redirect([String method, Uri url]);
767 767
768 /** 768 /**
769 * Detach the underlying socket from the HTTP client. When the 769 * Detach the underlying socket from the HTTP client. When the
770 * socket is detached the HTTP client will no longer perform any 770 * socket is detached the HTTP client will no longer perform any
771 * operations on it. 771 * operations on it.
772 * 772 *
773 * This is normally used when a HTTP upgrade is negotiated and the 773 * This is normally used when a HTTP upgrade is negotiated and the
774 * communication should continue with a different protocol. 774 * communication should continue with a different protocol.
775 */ 775 */
776 DetachedSocket detachSocket(); 776 DetachedSocket detachSocket();
777 777
778 /** 778 /**
779 * Get information about the client connection. Returns [null] if the socket 779 * Get information about the client connection. Returns [null] if the socket
780 * isn't available. 780 * isn't available.
781 */ 781 */
782 HttpConnectionInfo get connectionInfo(); 782 HttpConnectionInfo get connectionInfo;
783 } 783 }
784 784
785 785
786 /** 786 /**
787 * HTTP request for a client connection. 787 * HTTP request for a client connection.
788 */ 788 */
789 interface HttpClientRequest default _HttpClientRequest { 789 interface HttpClientRequest default _HttpClientRequest {
790 /** 790 /**
791 * Gets and sets the content length of the request. If the size of 791 * Gets and sets the content length of the request. If the size of
792 * the request is not known in advance set content length to -1, 792 * the request is not known in advance set content length to -1,
793 * which is also the default. 793 * which is also the default.
794 */ 794 */
795 int contentLength; 795 int contentLength;
796 796
797 /** 797 /**
798 * Returns the request headers. 798 * Returns the request headers.
799 */ 799 */
800 HttpHeaders get headers(); 800 HttpHeaders get headers;
801 801
802 /** 802 /**
803 * Cookies to present to the server (in the Cookie header). 803 * Cookies to present to the server (in the Cookie header).
804 */ 804 */
805 List<Cookie> get cookies(); 805 List<Cookie> get cookies;
806 806
807 /** 807 /**
808 * Gets and sets the requested persistent connection state. 808 * Gets and sets the requested persistent connection state.
809 * The default value is [:true:]. 809 * The default value is [:true:].
810 */ 810 */
811 bool persistentConnection; 811 bool persistentConnection;
812 812
813 /** 813 /**
814 * Returns the output stream for the request. This is used to write 814 * Returns the output stream for the request. This is used to write
815 * the request data. When all request data has been written close 815 * the request data. When all request data has been written close
816 * the stream to indicate the end of the request. 816 * the stream to indicate the end of the request.
817 * 817 *
818 * When this is accessed for the first time the request header is 818 * When this is accessed for the first time the request header is
819 * send. Calling any methods that will change the header after 819 * send. Calling any methods that will change the header after
820 * having retrieved the output stream will throw an exception. 820 * having retrieved the output stream will throw an exception.
821 */ 821 */
822 OutputStream get outputStream(); 822 OutputStream get outputStream;
823 } 823 }
824 824
825 825
826 /** 826 /**
827 * HTTP response for a client connection. 827 * HTTP response for a client connection.
828 */ 828 */
829 interface HttpClientResponse default _HttpClientResponse { 829 interface HttpClientResponse default _HttpClientResponse {
830 /** 830 /**
831 * Returns the status code. 831 * Returns the status code.
832 */ 832 */
833 int get statusCode(); 833 int get statusCode;
834 834
835 /** 835 /**
836 * Returns the reason phrase associated with the status code. 836 * Returns the reason phrase associated with the status code.
837 */ 837 */
838 String get reasonPhrase(); 838 String get reasonPhrase;
839 839
840 /** 840 /**
841 * Returns the content length of the request body. If the size of 841 * Returns the content length of the request body. If the size of
842 * the request body is not known in advance this -1. 842 * the request body is not known in advance this -1.
843 */ 843 */
844 int get contentLength(); 844 int get contentLength;
845 845
846 /** 846 /**
847 * Gets the persistent connection state returned by the server. 847 * Gets the persistent connection state returned by the server.
848 */ 848 */
849 bool get persistentConnection(); 849 bool get persistentConnection;
850 850
851 /** 851 /**
852 * Returns whether the status code is one of the normal redirect 852 * Returns whether the status code is one of the normal redirect
853 * codes [:HttpStatus.MOVED_PERMANENTLY:], [:HttpStatus.FOUND:], 853 * codes [:HttpStatus.MOVED_PERMANENTLY:], [:HttpStatus.FOUND:],
854 * [:HttpStatus.MOVED_TEMPORARILY:], [:HttpStatus.SEE_OTHER:] and 854 * [:HttpStatus.MOVED_TEMPORARILY:], [:HttpStatus.SEE_OTHER:] and
855 * [:HttpStatus.TEMPORARY_REDIRECT:]. 855 * [:HttpStatus.TEMPORARY_REDIRECT:].
856 */ 856 */
857 bool get isRedirect(); 857 bool get isRedirect;
858 858
859 /** 859 /**
860 * Returns the response headers. 860 * Returns the response headers.
861 */ 861 */
862 HttpHeaders get headers(); 862 HttpHeaders get headers;
863 863
864 /** 864 /**
865 * Cookies set by the server (from the Set-Cookie header). 865 * Cookies set by the server (from the Set-Cookie header).
866 */ 866 */
867 List<Cookie> get cookies(); 867 List<Cookie> get cookies;
868 868
869 /** 869 /**
870 * Returns the input stream for the response. This is used to read 870 * Returns the input stream for the response. This is used to read
871 * the response data. 871 * the response data.
872 */ 872 */
873 InputStream get inputStream(); 873 InputStream get inputStream;
874 } 874 }
875 875
876 /** 876 /**
877 * Connection information. 877 * Connection information.
878 */ 878 */
879 interface HttpConnectionInfo { 879 interface HttpConnectionInfo {
880 String get remoteHost(); 880 String get remoteHost;
881 int get remotePort(); 881 int get remotePort;
882 int get localPort(); 882 int get localPort;
883 } 883 }
884 884
885 885
886 /** 886 /**
887 * Redirect information. 887 * Redirect information.
888 */ 888 */
889 interface RedirectInfo { 889 interface RedirectInfo {
890 /** 890 /**
891 * Returns the status code used for the redirect. 891 * Returns the status code used for the redirect.
892 */ 892 */
893 int get statusCode(); 893 int get statusCode;
894 894
895 /** 895 /**
896 * Returns the method used for the redirect. 896 * Returns the method used for the redirect.
897 */ 897 */
898 String get method(); 898 String get method;
899 899
900 /** 900 /**
901 * Returns the location for the redirect. 901 * Returns the location for the redirect.
902 */ 902 */
903 Uri get location(); 903 Uri get location;
904 } 904 }
905 905
906 906
907 /** 907 /**
908 * When detaching a socket from either the [:HttpServer:] or the 908 * When detaching a socket from either the [:HttpServer:] or the
909 * [:HttpClient:] due to a HTTP connection upgrade there might be 909 * [:HttpClient:] due to a HTTP connection upgrade there might be
910 * unparsed data already read from the socket. This unparsed data 910 * unparsed data already read from the socket. This unparsed data
911 * together with the detached socket is returned in an instance of 911 * together with the detached socket is returned in an instance of
912 * this class. 912 * this class.
913 */ 913 */
914 interface DetachedSocket default _DetachedSocket { 914 interface DetachedSocket default _DetachedSocket {
915 Socket get socket(); 915 Socket get socket;
916 List<int> get unparsedData(); 916 List<int> get unparsedData;
917 } 917 }
918 918
919 919
920 class HttpException implements Exception { 920 class HttpException implements Exception {
921 const HttpException([String this.message = ""]); 921 const HttpException([String this.message = ""]);
922 String toString() => "HttpException: $message"; 922 String toString() => "HttpException: $message";
923 final String message; 923 final String message;
924 } 924 }
925 925
926 926
927 class RedirectException extends HttpException { 927 class RedirectException extends HttpException {
928 const RedirectException(String message, 928 const RedirectException(String message,
929 List<RedirectInfo> this.redirects) : super(message); 929 List<RedirectInfo> this.redirects) : super(message);
930 final List<RedirectInfo> redirects; 930 final List<RedirectInfo> redirects;
931 } 931 }
932 932
933 933
934 class RedirectLimitExceededException extends RedirectException { 934 class RedirectLimitExceededException extends RedirectException {
935 const RedirectLimitExceededException(List<RedirectInfo> redirects) 935 const RedirectLimitExceededException(List<RedirectInfo> redirects)
936 : super("Redirect limit exceeded", redirects); 936 : super("Redirect limit exceeded", redirects);
937 } 937 }
938 938
939 939
940 class RedirectLoopException extends RedirectException { 940 class RedirectLoopException extends RedirectException {
941 const RedirectLoopException(List<RedirectInfo> redirects) 941 const RedirectLoopException(List<RedirectInfo> redirects)
942 : super("Redirect loop detected", redirects); 942 : super("Redirect loop detected", redirects);
943 } 943 }
OLDNEW
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/bin/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698