Chromium Code Reviews| 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 _HttpHeaders implements HttpHeaders { | 5 class _HttpHeaders implements HttpHeaders { |
| 6 _HttpHeaders() : _headers = new Map<String, List<String>>(); | 6 _HttpHeaders() : _headers = new Map<String, List<String>>(); |
| 7 | 7 |
| 8 List<String> operator[](String name) { | 8 List<String> operator[](String name) { |
| 9 name = name.toLowerCase(); | 9 name = name.toLowerCase(); |
| 10 return _headers[name]; | 10 return _headers[name]; |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 | 702 |
| 703 void _updateContentLength(int bytes) { | 703 void _updateContentLength(int bytes) { |
| 704 if (_bodyBytesWritten + bytes > _contentLength) { | 704 if (_bodyBytesWritten + bytes > _contentLength) { |
| 705 throw new HttpException("Writing more than specified content length"); | 705 throw new HttpException("Writing more than specified content length"); |
| 706 } | 706 } |
| 707 _bodyBytesWritten += bytes; | 707 _bodyBytesWritten += bytes; |
| 708 } | 708 } |
| 709 | 709 |
| 710 HttpConnectionInfo get connectionInfo() { | |
|
Bill Hesse
2012/07/19 15:05:10
Why not => notation here?
| |
| 711 return _httpConnection.connectionInfo(); | |
| 712 } | |
| 713 | |
| 710 int _state; | 714 int _state; |
| 711 bool _headResponse; | 715 bool _headResponse; |
| 712 | 716 |
| 713 _HttpConnectionBase _httpConnection; | 717 _HttpConnectionBase _httpConnection; |
| 714 _HttpHeaders _headers; | 718 _HttpHeaders _headers; |
| 715 List<Cookie> _cookies; | 719 List<Cookie> _cookies; |
| 716 String _protocolVersion = "1.1"; | 720 String _protocolVersion = "1.1"; |
| 717 | 721 |
| 718 // Length of the content body. If this is set to -1 (default value) | 722 // Length of the content body. If this is set to -1 (default value) |
| 719 // when starting to send data chunked transfer encoding will be | 723 // when starting to send data chunked transfer encoding will be |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1234 _socket.onData = null; | 1238 _socket.onData = null; |
| 1235 _socket.onClosed = null; | 1239 _socket.onClosed = null; |
| 1236 _socket.onError = null; | 1240 _socket.onError = null; |
| 1237 _socket.outputStream.onNoPendingWrites = null; | 1241 _socket.outputStream.onNoPendingWrites = null; |
| 1238 Socket socket = _socket; | 1242 Socket socket = _socket; |
| 1239 _socket = null; | 1243 _socket = null; |
| 1240 if (onDetach != null) onDetach(); | 1244 if (onDetach != null) onDetach(); |
| 1241 return new _DetachedSocket(socket, _httpParser.unparsedData); | 1245 return new _DetachedSocket(socket, _httpParser.unparsedData); |
| 1242 } | 1246 } |
| 1243 | 1247 |
| 1248 HttpConnectionInfo get connectionInfo() { | |
| 1249 if (_socket == null || _closing || _error) return null; | |
| 1250 try { | |
| 1251 HttpConnectionInfo info = new _HttpConnectionInfo(); | |
| 1252 info.remoteHost = _socket.remoteHost; | |
|
Bill Hesse
2012/07/19 15:05:10
Why not have a constructor
_HttpConnectionInfo(thi
Anders Johnsen
2012/07/19 15:12:44
_HttpConnectionInfo is a simple data container. Us
| |
| 1253 info.remotePort = _socket.remotePort; | |
| 1254 info.localPort = _socket.port; | |
| 1255 return info; | |
| 1256 } catch (var e) { } | |
| 1257 return null; | |
| 1258 } | |
| 1259 | |
| 1244 abstract void _onConnectionClosed(e); | 1260 abstract void _onConnectionClosed(e); |
| 1245 abstract void _responseDone(); | 1261 abstract void _responseDone(); |
| 1246 | 1262 |
| 1247 void set _onNoPendingWrites(void callback()) { | 1263 void set _onNoPendingWrites(void callback()) { |
| 1248 if (!_error) { | 1264 if (!_error) { |
| 1249 _socket.outputStream.onNoPendingWrites = callback; | 1265 _socket.outputStream.onNoPendingWrites = callback; |
| 1250 } | 1266 } |
| 1251 } | 1267 } |
| 1252 | 1268 |
| 1253 int hashCode() => _hashCode; | 1269 int hashCode() => _hashCode; |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2093 } | 2109 } |
| 2094 | 2110 |
| 2095 Function _onOpen; | 2111 Function _onOpen; |
| 2096 Map<String, Queue<_SocketConnection>> _openSockets; | 2112 Map<String, Queue<_SocketConnection>> _openSockets; |
| 2097 Set<_SocketConnection> _activeSockets; | 2113 Set<_SocketConnection> _activeSockets; |
| 2098 Timer _evictionTimer; | 2114 Timer _evictionTimer; |
| 2099 bool _shutdown; // Has this HTTP client been shutdown? | 2115 bool _shutdown; // Has this HTTP client been shutdown? |
| 2100 } | 2116 } |
| 2101 | 2117 |
| 2102 | 2118 |
| 2119 class _HttpConnectionInfo implements HttpConnectionInfo { | |
| 2120 String remoteHost; | |
| 2121 String remotePort; | |
| 2122 String localPort; | |
| 2123 } | |
| 2124 | |
| 2125 | |
| 2103 class _DetachedSocket implements DetachedSocket { | 2126 class _DetachedSocket implements DetachedSocket { |
| 2104 _DetachedSocket(this._socket, this._unparsedData); | 2127 _DetachedSocket(this._socket, this._unparsedData); |
| 2105 Socket get socket() => _socket; | 2128 Socket get socket() => _socket; |
| 2106 List<int> get unparsedData() => _unparsedData; | 2129 List<int> get unparsedData() => _unparsedData; |
| 2107 Socket _socket; | 2130 Socket _socket; |
| 2108 List<int> _unparsedData; | 2131 List<int> _unparsedData; |
| 2109 } | 2132 } |
| 2110 | 2133 |
| 2111 | 2134 |
| 2112 class _RedirectInfo implements RedirectInfo { | 2135 class _RedirectInfo implements RedirectInfo { |
| 2113 const _RedirectInfo(int this.statusCode, | 2136 const _RedirectInfo(int this.statusCode, |
| 2114 String this.method, | 2137 String this.method, |
| 2115 Uri this.location); | 2138 Uri this.location); |
| 2116 final int statusCode; | 2139 final int statusCode; |
| 2117 final String method; | 2140 final String method; |
| 2118 final Uri location; | 2141 final Uri location; |
| 2119 } | 2142 } |
| OLD | NEW |