| 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 // Global constants. | 5 // Global constants. |
| 6 class _Const { | 6 class _Const { |
| 7 // Bytes for "HTTP". | 7 // Bytes for "HTTP". |
| 8 static const HTTP = const [72, 84, 84, 80]; | 8 static const HTTP = const [72, 84, 84, 80]; |
| 9 // Bytes for "HTTP/1.". | 9 // Bytes for "HTTP/1.". |
| 10 static const HTTP1DOT = const [72, 84, 84, 80, 47, 49, 46]; | 10 static const HTTP1DOT = const [72, 84, 84, 80, 47, 49, 46]; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // States of the HTTP parser state machine. | 89 // States of the HTTP parser state machine. |
| 90 class _MessageType { | 90 class _MessageType { |
| 91 static const int UNDETERMINED = 0; | 91 static const int UNDETERMINED = 0; |
| 92 static const int REQUEST = 1; | 92 static const int REQUEST = 1; |
| 93 static const int RESPONSE = 0; | 93 static const int RESPONSE = 0; |
| 94 } | 94 } |
| 95 | 95 |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * HTTP parser which parses the HTTP stream as data is supplied | 98 * HTTP parser which parses the HTTP stream as data is supplied |
| 99 * through the [:writeList:] and [:connectionClosed:] methods. As the | 99 * through the [:streamData:] and [:streamDone:] methods. As the |
| 100 * data is parsed the following callbacks are called: | 100 * data is parsed the following callbacks are called: |
| 101 * | 101 * |
| 102 * [:requestStart:] | 102 * [:requestStart:] |
| 103 * [:responseStart:] | 103 * [:responseStart:] |
| 104 * [:dataReceived:] | 104 * [:dataReceived:] |
| 105 * [:dataEnd:] | 105 * [:dataEnd:] |
| 106 * [:closed:] | 106 * [:closed:] |
| 107 * [:error:] | 107 * [:error:] |
| 108 * | 108 * |
| 109 * If an HTTP parser error occours it is possible to get an exception | 109 * If an HTTP parser error occours it is possible to get an exception |
| 110 * thrown from the [:writeList:] and [:connectionClosed:] methods if | 110 * thrown from the [:streamData:] and [:streamDone:] methods if |
| 111 * the error callback is not set. | 111 * the error callback is not set. |
| 112 * | 112 * |
| 113 * The connection upgrades (e.g. switching from HTTP/1.1 to the | 113 * The connection upgrades (e.g. switching from HTTP/1.1 to the |
| 114 * WebSocket protocol) is handled in a special way. If connection | 114 * WebSocket protocol) is handled in a special way. If connection |
| 115 * upgrade is specified in the headers, then on the callback to | 115 * upgrade is specified in the headers, then on the callback to |
| 116 * [:responseStart:] the [:upgrade:] property on the [:HttpParser:] | 116 * [:responseStart:] the [:upgrade:] property on the [:HttpParser:] |
| 117 * object will be [:true:] indicating that from now on the protocol is | 117 * object will be [:true:] indicating that from now on the protocol is |
| 118 * not HTTP anymore and no more callbacks will happen, that is | 118 * not HTTP anymore and no more callbacks will happen, that is |
| 119 * [:dataReceived:] and [:dataEnd:] are not called in this case as | 119 * [:dataReceived:] and [:dataEnd:] are not called in this case as |
| 120 * there is no more HTTP data. After the upgrade the method | 120 * there is no more HTTP data. After the upgrade the method |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 Function error; | 783 Function error; |
| 784 Function closed; | 784 Function closed; |
| 785 } | 785 } |
| 786 | 786 |
| 787 | 787 |
| 788 class HttpParserException implements Exception { | 788 class HttpParserException implements Exception { |
| 789 const HttpParserException([String this.message = ""]); | 789 const HttpParserException([String this.message = ""]); |
| 790 String toString() => "HttpParserException: $message"; | 790 String toString() => "HttpParserException: $message"; |
| 791 final String message; | 791 final String message; |
| 792 } | 792 } |
| OLD | NEW |