OLD | NEW |
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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 * send. Calling any methods that will change the header after | 381 * send. Calling any methods that will change the header after |
382 * having retrieved the output stream will throw an exception. | 382 * having retrieved the output stream will throw an exception. |
383 */ | 383 */ |
384 OutputStream get outputStream(); | 384 OutputStream get outputStream(); |
385 | 385 |
386 /** | 386 /** |
387 * Detach the underlying socket from the HTTP server. When the | 387 * Detach the underlying socket from the HTTP server. When the |
388 * socket is detached the HTTP server will no longer perform any | 388 * socket is detached the HTTP server will no longer perform any |
389 * operations on it. | 389 * operations on it. |
390 * | 390 * |
391 * This is normally used when a HTTP upgraded request is received | 391 * This is normally used when a HTTP upgrade request is received |
392 * and the communication should continue with a different protocol. | 392 * and the communication should continue with a different protocol. |
393 */ | 393 */ |
394 Socket detachSocket(); | 394 DetachedSocket detachSocket(); |
395 } | 395 } |
396 | 396 |
397 | 397 |
398 /** | 398 /** |
399 * HTTP client factory. | 399 * HTTP client factory. |
400 */ | 400 */ |
401 interface HttpClient default _HttpClient { | 401 interface HttpClient default _HttpClient { |
402 static final int DEFAULT_HTTP_PORT = 80; | 402 static final int DEFAULT_HTTP_PORT = 80; |
403 | 403 |
404 HttpClient(); | 404 HttpClient(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 * all headers of the response are received and data is ready to be | 478 * all headers of the response are received and data is ready to be |
479 * received. | 479 * received. |
480 */ | 480 */ |
481 void set onResponse(void callback(HttpClientResponse response)); | 481 void set onResponse(void callback(HttpClientResponse response)); |
482 | 482 |
483 /** | 483 /** |
484 * Sets the handler that gets called if an error occurs while | 484 * Sets the handler that gets called if an error occurs while |
485 * connecting or processing the HTTP request. | 485 * connecting or processing the HTTP request. |
486 */ | 486 */ |
487 void set onError(void callback(e)); | 487 void set onError(void callback(e)); |
| 488 |
| 489 /** |
| 490 * Detach the underlying socket from the HTTP client. When the |
| 491 * socket is detached the HTTP client will no longer perform any |
| 492 * operations on it. |
| 493 * |
| 494 * This is normally used when a HTTP upgrade is negotiated and the |
| 495 * communication should continue with a different protocol. |
| 496 */ |
| 497 DetachedSocket detachSocket(); |
488 } | 498 } |
489 | 499 |
490 | 500 |
491 /** | 501 /** |
492 * HTTP request for a client connection. | 502 * HTTP request for a client connection. |
493 */ | 503 */ |
494 interface HttpClientRequest default _HttpClientRequest { | 504 interface HttpClientRequest default _HttpClientRequest { |
495 /** | 505 /** |
496 * Gets and sets the content length of the request. If the size of | 506 * Gets and sets the content length of the request. If the size of |
497 * the request is not known in advance set content length to -1, | 507 * the request is not known in advance set content length to -1, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 HttpHeaders get headers(); | 553 HttpHeaders get headers(); |
544 | 554 |
545 /** | 555 /** |
546 * Returns the input stream for the response. This is used to read | 556 * Returns the input stream for the response. This is used to read |
547 * the response data. | 557 * the response data. |
548 */ | 558 */ |
549 InputStream get inputStream(); | 559 InputStream get inputStream(); |
550 } | 560 } |
551 | 561 |
552 | 562 |
| 563 /** |
| 564 * When detaching a socket from either the [:HttpServer:] or the |
| 565 * [:HttpClient:] due to a HTTP connection upgrade there might be |
| 566 * unparsed data already read from the socket. This unparsed data |
| 567 * together with the detached socket is returned in an instance of |
| 568 * this class. |
| 569 */ |
| 570 interface DetachedSocket default _DetachedSocket { |
| 571 Socket get socket(); |
| 572 List<int> get unparsedData(); |
| 573 } |
| 574 |
| 575 |
553 class HttpException implements Exception { | 576 class HttpException implements Exception { |
554 const HttpException([String this.message = ""]); | 577 const HttpException([String this.message = ""]); |
555 String toString() => "HttpException: $message"; | 578 String toString() => "HttpException: $message"; |
556 final String message; | 579 final String message; |
557 } | 580 } |
OLD | NEW |