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

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

Issue 9834008: Add error handling to the HTTP library (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « no previous file | runtime/bin/http_impl.dart » ('j') | runtime/bin/http_impl.dart » ('J')
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 /** 76 /**
77 * Returns the port that the server is listening on. This can be 77 * Returns the port that the server is listening on. This can be
78 * used to get the actual port used when a value of 0 for [port] is 78 * used to get the actual port used when a value of 0 for [port] is
79 * specified in the [listen] call. 79 * specified in the [listen] call.
80 */ 80 */
81 int get port(); 81 int get port();
82 82
83 /** 83 /**
84 * Sets the handler that gets called when a new HTTP request is received. 84 * Sets the handler that gets called when a new HTTP request is received.
85 */ 85 */
86 void set onRequest(void handler(HttpRequest, HttpResponse)); 86 void set onRequest(void callback(HttpRequest, HttpResponse));
87 87
88 /** 88 /**
89 * Sets the error handler that is called when a connection error occurs. 89 * Sets the error handler that is called when a connection error occurs.
90 */ 90 */
91 void set onError(void handler(String errorMessage)); 91 void set onError(void callback(Exception e));
92 } 92 }
93 93
94 94
95 /** 95 /**
96 * Http request delivered to the HTTP server callback. 96 * Http request delivered to the HTTP server callback.
97 */ 97 */
98 interface HttpRequest default _HttpRequest { 98 interface HttpRequest default _HttpRequest {
99 /** 99 /**
100 * Returns the content length of the request body. If the size of 100 * Returns the content length of the request body. If the size of
101 * the request body is not known in advance this -1. 101 * the request body is not known in advance this -1.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 * 271 *
272 * The setting of all handlers is optional. If [onRequest] is not set 272 * The setting of all handlers is optional. If [onRequest] is not set
273 * the request will be send without any additional headers and an 273 * the request will be send without any additional headers and an
274 * empty body. If [onResponse] is not set the response will be read 274 * empty body. If [onResponse] is not set the response will be read
275 * and discarded. 275 * and discarded.
276 */ 276 */
277 interface HttpClientConnection { 277 interface HttpClientConnection {
278 /** 278 /**
279 * Sets the handler that is called when the connection is established. 279 * Sets the handler that is called when the connection is established.
280 */ 280 */
281 void set onRequest(void handler(HttpClientRequest request)); 281 void set onRequest(void callback(HttpClientRequest request));
282 282
283 /** 283 /**
284 * Sets callback to be called when the request has been send and 284 * Sets callback to be called when the request has been send and
285 * the response is ready for processing. The callback is called when 285 * the response is ready for processing. The callback is called when
286 * all headers of the response are received and data is ready to be 286 * all headers of the response are received and data is ready to be
287 * received. 287 * received.
288 */ 288 */
289 void set onResponse(void handler(HttpClientResponse response)); 289 void set onResponse(void callback(HttpClientResponse response));
290 290
291 /** 291 /**
292 * Sets the handler that gets called if an error occurs while 292 * Sets the handler that gets called if an error occurs while
293 * processing the HTTP request. 293 * connecting or processing the HTTP request.
294 */ 294 */
295 void set onError(void handler(HttpException e)); 295 void set onError(void callback(Exception e));
296 } 296 }
297 297
298 298
299 /** 299 /**
300 * HTTP request for a client connection. 300 * HTTP request for a client connection.
301 */ 301 */
302 interface HttpClientRequest default _HttpClientRequest { 302 interface HttpClientRequest default _HttpClientRequest {
303 /** 303 /**
304 * Gets and sets the content length of the request. If the size of 304 * Gets and sets the content length of the request. If the size of
305 * the request is not known in advance set content length to -1, 305 * the request is not known in advance set content length to -1,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 */ 395 */
396 InputStream get inputStream(); 396 InputStream get inputStream();
397 } 397 }
398 398
399 399
400 class HttpException implements Exception { 400 class HttpException implements Exception {
401 const HttpException([String this.message = ""]); 401 const HttpException([String this.message = ""]);
402 String toString() => "HttpException: $message"; 402 String toString() => "HttpException: $message";
403 final String message; 403 final String message;
404 } 404 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/http_impl.dart » ('j') | runtime/bin/http_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698