| 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 class _HttpRequestResponseBase { | 5 class _HttpRequestResponseBase { |
| 6 _HttpRequestResponseBase(_HttpConnectionBase this._httpConnection) | 6 _HttpRequestResponseBase(_HttpConnectionBase this._httpConnection) |
| 7 : _contentLength = -1, | 7 : _contentLength = -1, |
| 8 _keepAlive = false, | 8 _keepAlive = false, |
| 9 _headers = new Map(); | 9 _headers = new Map(); |
| 10 | 10 |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 _httpParser.requestStart = | 886 _httpParser.requestStart = |
| 887 (method, uri) => _onRequestStart(method, uri); | 887 (method, uri) => _onRequestStart(method, uri); |
| 888 _httpParser.responseStart = | 888 _httpParser.responseStart = |
| 889 (statusCode, reasonPhrase) => | 889 (statusCode, reasonPhrase) => |
| 890 _onResponseStart(statusCode, reasonPhrase); | 890 _onResponseStart(statusCode, reasonPhrase); |
| 891 _httpParser.headerReceived = | 891 _httpParser.headerReceived = |
| 892 (name, value) => _onHeaderReceived(name, value); | 892 (name, value) => _onHeaderReceived(name, value); |
| 893 _httpParser.headersComplete = () => _onHeadersComplete(); | 893 _httpParser.headersComplete = () => _onHeadersComplete(); |
| 894 _httpParser.dataReceived = (data) => _onDataReceived(data); | 894 _httpParser.dataReceived = (data) => _onDataReceived(data); |
| 895 _httpParser.dataEnd = () => _onDataEnd(); | 895 _httpParser.dataEnd = () => _onDataEnd(); |
| 896 // Tell the HTTP parser the method it is expecting a response to. |
| 897 _httpParser.responseToMethod = _method; |
| 898 |
| 896 onDisconnect = _onDisconnected; | 899 onDisconnect = _onDisconnected; |
| 897 } | 900 } |
| 898 | 901 |
| 899 HttpClientRequest open(String method, String uri) { | 902 HttpClientRequest open(String method, String uri) { |
| 903 _method = method; |
| 900 _request = new _HttpClientRequest(method, uri, this); | 904 _request = new _HttpClientRequest(method, uri, this); |
| 901 _request.keepAlive = true; | 905 _request.keepAlive = true; |
| 902 _response = new _HttpClientResponse(this); | 906 _response = new _HttpClientResponse(this); |
| 903 return _request; | 907 return _request; |
| 904 } | 908 } |
| 905 | 909 |
| 906 void _onRequestStart(String method, String uri) { | 910 void _onRequestStart(String method, String uri) { |
| 907 // TODO(sgjesse): Error handling. | 911 // TODO(sgjesse): Error handling. |
| 908 } | 912 } |
| 909 | 913 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 } | 955 } |
| 952 | 956 |
| 953 | 957 |
| 954 Function _onRequest; | 958 Function _onRequest; |
| 955 Function _onResponse; | 959 Function _onResponse; |
| 956 | 960 |
| 957 _HttpClient _client; | 961 _HttpClient _client; |
| 958 _SocketConnection _socketConn; | 962 _SocketConnection _socketConn; |
| 959 HttpClientRequest _request; | 963 HttpClientRequest _request; |
| 960 HttpClientResponse _response; | 964 HttpClientResponse _response; |
| 965 String _method; |
| 961 | 966 |
| 962 // Callbacks. | 967 // Callbacks. |
| 963 var requestReceived; | 968 var requestReceived; |
| 964 | 969 |
| 965 } | 970 } |
| 966 | 971 |
| 967 | 972 |
| 968 // Class for holding keep-alive sockets in the cache for the HTTP | 973 // Class for holding keep-alive sockets in the cache for the HTTP |
| 969 // client together with the connection information. | 974 // client together with the connection information. |
| 970 class _SocketConnection { | 975 class _SocketConnection { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 _onError = callback; | 1159 _onError = callback; |
| 1155 } | 1160 } |
| 1156 | 1161 |
| 1157 Function _onOpen; | 1162 Function _onOpen; |
| 1158 Function _onError; | 1163 Function _onError; |
| 1159 Map<String, Queue<_SocketConnection>> _openSockets; | 1164 Map<String, Queue<_SocketConnection>> _openSockets; |
| 1160 Set<_SocketConnection> _activeSockets; | 1165 Set<_SocketConnection> _activeSockets; |
| 1161 Timer _evictionTimer; | 1166 Timer _evictionTimer; |
| 1162 bool _shutdown; // Has this HTTP client been shutdown? | 1167 bool _shutdown; // Has this HTTP client been shutdown? |
| 1163 } | 1168 } |
| OLD | NEW |