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

Side by Side Diff: sdk/lib/io/http.dart

Issue 203263003: Fix documentation in dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review fixes. Created 6 years, 9 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 | « sdk/lib/async/async.dart ('k') | sdk/lib/io/io_sink.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) 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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * HTTP status codes. 8 * HTTP status codes.
9 */ 9 */
10 abstract class HttpStatus { 10 abstract class HttpStatus {
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 741
742 /** 742 /**
743 * A server-side object 743 * A server-side object
744 * that contains the content of and information about an HTTP request. 744 * that contains the content of and information about an HTTP request.
745 * 745 *
746 * __Note__: Check out the 746 * __Note__: Check out the
747 * [http_server](http://pub.dartlang.org/packages/http_server) 747 * [http_server](http://pub.dartlang.org/packages/http_server)
748 * package, which makes working with the low-level 748 * package, which makes working with the low-level
749 * dart:io HTTP server subsystem easier. 749 * dart:io HTTP server subsystem easier.
750 * 750 *
751 * HttpRequest objects are generated by an [HttpServer], 751 * `HttpRequest` objects are generated by an [HttpServer],
752 * which listens for HTTP requests on a specific host and port. 752 * which listens for HTTP requests on a specific host and port.
753 * For each request received, the HttpServer, which is a [Stream], 753 * For each request received, the HttpServer, which is a [Stream],
754 * generates an HttpRequest object and adds it to the stream. 754 * generates an `HttpRequest` object and adds it to the stream.
755 * 755 *
756 * An HttpRequest object delivers the body content of the request 756 * An `HttpRequest` object delivers the body content of the request
757 * as a stream of bytes. 757 * as a stream of byte lists.
758 * The object also contains information about the request, 758 * The object also contains information about the request,
759 * such as the method, URI, and headers. 759 * such as the method, URI, and headers.
760 * 760 *
761 * In the following code, an HttpServer listens 761 * In the following code, an HttpServer listens
762 * for HTTP requests and, within the callback function, 762 * for HTTP requests and, within the callback function,
763 * uses the HttpRequest object's `method` property to dispatch requests. 763 * uses the `HttpRequest` object's `method` property to dispatch requests.
764 * 764 *
765 * final HOST = InternetAddress.LOOPBACK_IP_V4; 765 * final HOST = InternetAddress.LOOPBACK_IP_V4;
766 * final PORT = 4040; 766 * final PORT = 4040;
767 * 767 *
768 * HttpServer.bind(HOST, PORT).then((_server) { 768 * HttpServer.bind(HOST, PORT).then((_server) {
769 * _server.listen((HttpRequest request) { 769 * _server.listen((HttpRequest request) {
770 * switch (request.method) { 770 * switch (request.method) {
771 * case 'GET': 771 * case 'GET':
772 * handleGetRequest(request); 772 * handleGetRequest(request);
773 * break; 773 * break;
774 * case 'POST': 774 * case 'POST':
775 * ... 775 * ...
776 * } 776 * }
777 * }, 777 * },
778 * onError: handleError); // listen() failed. 778 * onError: handleError); // listen() failed.
779 * }).catchError(handleError); 779 * }).catchError(handleError);
780 * 780 *
781 * Listen to the HttpRequest stream to handle the 781 * Listen to the `HttpRequest` stream to handle the
782 * data and be notified once the entire body is received. 782 * data and be notified once the entire body is received.
783 * An HttpRequest object contains an [HttpResponse] object, 783 * An `HttpRequest` object contains an [HttpResponse] object,
784 * to which the server can write its response. 784 * to which the server can write its response.
785 * For example, here's a skeletal callback function 785 * For example, here's a skeletal callback function
786 * that responds to a request: 786 * that responds to a request:
787 * 787 *
788 * void handleGetRequest(HttpRequest req) { 788 * void handleGetRequest(HttpRequest req) {
789 * HttpResponse res = req.response; 789 * HttpResponse res = req.response;
790 * var body = []; 790 * var body = [];
791 * req.listen((List<int> buffer) => body.add(buffer), 791 * req.listen((List<int> buffer) => body.add(buffer),
792 * onDone: () { 792 * onDone: () {
793 * res.write('Received ${body.length} for request '); 793 * res.write('Received ${body.length} for request ');
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 * HttpClientRequest request = ... 1368 * HttpClientRequest request = ...
1369 * request.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain"); 1369 * request.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain");
1370 * request.write(...); // Strings written will be ISO-8859-1 encoded. 1370 * request.write(...); // Strings written will be ISO-8859-1 encoded.
1371 * 1371 *
1372 * If an unsupported encoding is used an exception will be thrown if 1372 * If an unsupported encoding is used an exception will be thrown if
1373 * using one of the write methods taking a string. 1373 * using one of the write methods taking a string.
1374 */ 1374 */
1375 abstract class HttpClientRequest implements IOSink { 1375 abstract class HttpClientRequest implements IOSink {
1376 /** 1376 /**
1377 * Gets and sets the requested persistent connection state. 1377 * Gets and sets the requested persistent connection state.
1378 *
1378 * The default value is [:true:]. 1379 * The default value is [:true:].
1379 */ 1380 */
1380 bool persistentConnection; 1381 bool persistentConnection;
1381 1382
1382 /** 1383 /**
1383 * Set this property to [:true:] if this request should 1384 * Set this property to [:true:] if this request should
1384 * automatically follow redirects. The default is [:true:]. 1385 * automatically follow redirects. The default is [:true:].
1385 * 1386 *
1386 * Automatic redirect will only happen for "GET" and "HEAD" requests 1387 * Automatic redirect will only happen for "GET" and "HEAD" requests
1387 * and only for the status codes [:HttpHeaders.MOVED_PERMANENTLY:] 1388 * and only for the status codes [:HttpHeaders.MOVED_PERMANENTLY:]
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 class RedirectException implements HttpException { 1643 class RedirectException implements HttpException {
1643 final String message; 1644 final String message;
1644 final List<RedirectInfo> redirects; 1645 final List<RedirectInfo> redirects;
1645 1646
1646 const RedirectException(this.message, this.redirects); 1647 const RedirectException(this.message, this.redirects);
1647 1648
1648 String toString() => "RedirectException: $message"; 1649 String toString() => "RedirectException: $message";
1649 1650
1650 Uri get uri => redirects.last.location; 1651 Uri get uri => redirects.last.location;
1651 } 1652 }
OLDNEW
« no previous file with comments | « sdk/lib/async/async.dart ('k') | sdk/lib/io/io_sink.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698