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

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

Issue 10082003: Start refactoring of the HTTP header handling (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed second round of comments Created 8 years, 8 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 | « runtime/bin/http.dart ('k') | runtime/bin/http_parser.dart » ('j') | no next file with comments »
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 class _HttpHeaders implements HttpHeaders {
6 _HttpHeaders() : _headers = new Map<String, List<String>>();
7
8 List<String> operator[](String name) {
9 name = name.toLowerCase();
10 return _headers[name];
11 }
12
13 String value(String name) {
14 name = name.toLowerCase();
15 List<String> values = _headers[name];
16 if (values == null) return null;
17 if (values.length > 1) {
18 throw new HttpException("More than one value for header $name");
19 }
20 return values[0];
21 }
22
23 void add(String name, Object value) {
24 if (value is List) {
25 for (int i = 0; i < value.length; i++) {
26 _add(name, vlaie[i]);
27 }
28 } else {
29 _add(name, value);
30 }
31 }
32
33 void set(String name, Object value) {
34 removeAll(name);
35 add(name, value);
36 }
37
38 void remove(String name, Object value) {
39 name = name.toLowerCase();
40 List<String> values = _headers[name];
41 if (values != null) {
42 int index = values.indexOf(value);
43 if (index != -1) {
44 values.removeRange(index, 1);
45 }
46 }
47 }
48
49 void removeAll(String name) {
50 name = name.toLowerCase();
51 _headers.remove(name);
52 }
53
54 String get host() => _host;
55 void set host(String host) {
56 _host = host;
57 _updateHostHeader();
58 }
59
60 int get port() => _port;
61 void set port(int port) {
62 _port = port;
63 _updateHostHeader();
64 }
65
66 Date get expires() {
67 if (_expires == null) {
68 List<String> values = _headers["expires"];
69 if (values != null) {
70 _expires = _HttpUtils.parseDate(values[0]);
71 }
72 }
73 return _expires;
74 }
75
76 void set expires(Date expires) {
77 _expires = expires;
78 // Format "Expires" header with date in Greenwich Mean Time (GMT).
79 String formatted =
80 _HttpUtils.formatDate(_expires.changeTimeZone(new TimeZone.utc()));
81 _set("expires", formatted);
82 }
83
84 void _add(String name, Object value) {
85 // TODO(sgjesse): Add immutable state throw HttpException is immutable.
86 if (name.toLowerCase() == "expires") {
87 if (value is Date) {
88 expires = value;
89 } else if (value is String) {
90 expires = _HttpUtils.parseDate(value);
91 } else {
92 throw new HttpException("Unexpected type for header named $name");
93 }
94 } else if (name.toLowerCase() == "host") {
95 int pos = value.indexOf(":");
96 if (pos == -1) {
97 _host = value;
98 _port = HttpClient.DEFAULT_HTTP_PORT;
99 } else {
100 _host = value.substring(0, pos);
101 if (pos + 1 == value.length) {
102 _port = HttpClient.DEFAULT_HTTP_PORT;
103 } else {
104 _port = Math.parseInt(value.substring(pos + 1));
105 }
106 }
107 _updateHostHeader();
108 } else {
109 name = name.toLowerCase();
110 List<String> values = _headers[name];
111 if (values == null) {
112 values = new List<String>();
113 _headers[name] = values;
114 }
115 values.add(value.toString());
116 }
117 }
118
119 void _set(String name, String value) {
120 name = name.toLowerCase();
121 List<String> values = new List<String>();
122 _headers[name] = values;
123 values.add(value);
124 }
125
126 _updateHostHeader() {
127 String portPart = _port == HttpClient.DEFAULT_HTTP_PORT ? "" : ":$_port";
128 _set("host", "$host$portPart");
129 }
130
131 _write(_HttpConnectionBase connection) {
132 final COLONSP = const [_CharCode.COLON, _CharCode.SP];
133 final COMMASP = const [_CharCode.COMMA, _CharCode.SP];
134 final CRLF = const [_CharCode.CR, _CharCode.LF];
135
136 // Format headers.
137 _headers.forEach((String name, List<String> values) {
138 List<int> data;
139 data = name.charCodes();
140 connection._write(data);
141 connection._write(COLONSP);
142 for (int i = 0; i < values.length; i++) {
143 if (i > 0) {
144 connection._write(COMMASP);
145 }
146 data = values[i].charCodes();
147 connection._write(data);
148 }
149 connection._write(CRLF);
150 });
151 }
152
153 String toString() {
154 StringBuffer sb = new StringBuffer();
155 _headers.forEach((String name, List<String> values) {
156 sb.add(name);
157 sb.add(": ");
158 for (int i = 0; i < values.length; i++) {
159 if (i > 0) {
160 sb.add(": ");
161 }
162 sb.add(values[i]);
163 }
164 sb.add("\n");
165 });
166 return sb.toString();
167 }
168
169 Map<String, List<String>> _headers;
170
171 String _host;
172 int _port;
173 Date _expires;
174 }
175
176
5 class _HttpRequestResponseBase { 177 class _HttpRequestResponseBase {
6 _HttpRequestResponseBase(_HttpConnectionBase this._httpConnection) 178 _HttpRequestResponseBase(_HttpConnectionBase this._httpConnection)
7 : _contentLength = -1, 179 : _contentLength = -1,
8 _headers = new Map(); 180 _headers = new _HttpHeaders();
9 181
10 int get contentLength() => _contentLength; 182 int get contentLength() => _contentLength;
11 Map get headers() => _headers; 183 HttpHeaders get headers() => _headers;
12
13 void _setHeader(String name, String value) {
14 _headers[name.toLowerCase()] = value;
15 }
16 184
17 bool _write(List<int> data, bool copyBuffer) { 185 bool _write(List<int> data, bool copyBuffer) {
18 bool allWritten = true; 186 bool allWritten = true;
19 if (data.length > 0) { 187 if (data.length > 0) {
20 if (_contentLength < 0) { 188 if (_contentLength < 0) {
21 // Write chunk size if transfer encoding is chunked. 189 // Write chunk size if transfer encoding is chunked.
22 _writeHexString(data.length); 190 _writeHexString(data.length);
23 _writeCRLF(); 191 _writeCRLF();
24 _httpConnection._write(data, copyBuffer); 192 _httpConnection._write(data, copyBuffer);
25 allWritten = _writeCRLF(); 193 allWritten = _writeCRLF();
(...skipping 23 matching lines...) Expand all
49 bool _writeDone() { 217 bool _writeDone() {
50 bool allWritten = true; 218 bool allWritten = true;
51 if (_contentLength < 0) { 219 if (_contentLength < 0) {
52 // Terminate the content if transfer encoding is chunked. 220 // Terminate the content if transfer encoding is chunked.
53 allWritten = _httpConnection._write(_Const.END_CHUNKED); 221 allWritten = _httpConnection._write(_Const.END_CHUNKED);
54 } 222 }
55 return allWritten; 223 return allWritten;
56 } 224 }
57 225
58 bool _writeHeaders() { 226 bool _writeHeaders() {
59 List<int> data; 227 _headers._write(_httpConnection);
60
61 // Format headers.
62 _headers.forEach((String name, String value) {
63 data = name.charCodes();
64 _httpConnection._write(data);
65 data = ": ".charCodes();
66 _httpConnection._write(data);
67 data = value.charCodes();
68 _httpConnection._write(data);
69 _writeCRLF();
70 });
71 // Terminate header. 228 // Terminate header.
72 return _writeCRLF(); 229 return _writeCRLF();
73 } 230 }
74 231
75 bool _writeHexString(int x) { 232 bool _writeHexString(int x) {
76 final List<int> hexDigits = [0x30, 0x31, 0x32, 0x33, 0x34, 233 final List<int> hexDigits = [0x30, 0x31, 0x32, 0x33, 0x34,
77 0x35, 0x36, 0x37, 0x38, 0x39, 234 0x35, 0x36, 0x37, 0x38, 0x39,
78 0x41, 0x42, 0x43, 0x44, 0x45, 0x46]; 235 0x41, 0x42, 0x43, 0x44, 0x45, 0x46];
79 ByteArray hex = new ByteArray(10); 236 ByteArray hex = new ByteArray(10);
80 int index = hex.length; 237 int index = hex.length;
81 while (x > 0) { 238 while (x > 0) {
82 index--; 239 index--;
83 hex[index] = hexDigits[x % 16]; 240 hex[index] = hexDigits[x % 16];
84 x = x >> 4; 241 x = x >> 4;
85 } 242 }
86 return _httpConnection._writeFrom(hex, index, hex.length - index); 243 return _httpConnection._writeFrom(hex, index, hex.length - index);
87 } 244 }
88 245
89 bool _writeCRLF() { 246 bool _writeCRLF() {
90 final CRLF = const [_CharCode.CR, _CharCode.LF]; 247 final CRLF = const [_CharCode.CR, _CharCode.LF];
91 return _httpConnection._write(CRLF); 248 return _httpConnection._write(CRLF);
92 } 249 }
93 250
94 bool _writeSP() { 251 bool _writeSP() {
95 final SP = const [_CharCode.SP]; 252 final SP = const [_CharCode.SP];
96 return _httpConnection._write(SP); 253 return _httpConnection._write(SP);
97 } 254 }
98 255
99 _HttpConnectionBase _httpConnection; 256 _HttpConnectionBase _httpConnection;
100 Map<String, String> _headers; 257 _HttpHeaders _headers;
101 258
102 // Length of the content body. If this is set to -1 (default value) 259 // Length of the content body. If this is set to -1 (default value)
103 // when starting to send data chunked transfer encoding will be 260 // when starting to send data chunked transfer encoding will be
104 // used. 261 // used.
105 int _contentLength; 262 int _contentLength;
106 } 263 }
107 264
108 265
109 // Parsed HTTP request providing information on the HTTP headers. 266 // Parsed HTTP request providing information on the HTTP headers.
110 class _HttpRequest extends _HttpRequestResponseBase implements HttpRequest { 267 class _HttpRequest extends _HttpRequestResponseBase implements HttpRequest {
(...skipping 12 matching lines...) Expand all
123 return _inputStream; 280 return _inputStream;
124 } 281 }
125 282
126 void _onRequestStart(String method, String uri, String version) { 283 void _onRequestStart(String method, String uri, String version) {
127 _method = method; 284 _method = method;
128 _uri = uri; 285 _uri = uri;
129 _parseRequestUri(uri); 286 _parseRequestUri(uri);
130 } 287 }
131 288
132 void _onHeaderReceived(String name, String value) { 289 void _onHeaderReceived(String name, String value) {
133 _setHeader(name, value); 290 _headers.add(name, value);
134 } 291 }
135 292
136 void _onHeadersComplete() { 293 void _onHeadersComplete() {
137 // Prepare for receiving data. 294 // Prepare for receiving data.
138 _buffer = new _BufferList(); 295 _buffer = new _BufferList();
139 } 296 }
140 297
141 void _onDataReceived(List<int> data) { 298 void _onDataReceived(List<int> data) {
142 _buffer.add(data); 299 _buffer.add(data);
143 if (_inputStream != null) _inputStream._dataReceived(); 300 if (_inputStream != null) _inputStream._dataReceived();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (_outputStream != null) throw new HttpException("Header already sent"); 369 if (_outputStream != null) throw new HttpException("Header already sent");
213 _statusCode = statusCode; 370 _statusCode = statusCode;
214 } 371 }
215 372
216 String get reasonPhrase() => _findReasonPhrase(_statusCode); 373 String get reasonPhrase() => _findReasonPhrase(_statusCode);
217 void set reasonPhrase(String reasonPhrase) { 374 void set reasonPhrase(String reasonPhrase) {
218 if (_outputStream != null) throw new HttpException("Header already sent"); 375 if (_outputStream != null) throw new HttpException("Header already sent");
219 _reasonPhrase = reasonPhrase; 376 _reasonPhrase = reasonPhrase;
220 } 377 }
221 378
222 Date get expires() => _expires;
223 void set expires(Date expires) {
224 if (_outputStream != null) throw new HttpException("Header already sent");
225 _expires = expires;
226 // Format "Expires" header with date in Greenwich Mean Time (GMT).
227 String formatted =
228 _HttpUtils.formatDate(_expires.changeTimeZone(new TimeZone.utc()));
229 _setHeader("Expires", formatted);
230 }
231
232 // Set a header on the response. NOTE: If the same header is set
233 // more than once only the last one will be part of the response.
234 void setHeader(String name, String value) {
235 if (_outputStream != null) return new HttpException("Header already sent");
236 if (name.toLowerCase() == "expires") {
237 expires = _HttpUtils.parseDate(value);
238 } else {
239 _setHeader(name, value);
240 }
241 }
242
243 OutputStream get outputStream() { 379 OutputStream get outputStream() {
244 if (_state == DONE) throw new HttpException("Response closed"); 380 if (_state == DONE) throw new HttpException("Response closed");
245 if (_outputStream == null) { 381 if (_outputStream == null) {
246 // Ensure that headers are written. 382 // Ensure that headers are written.
247 if (_state == START) { 383 if (_state == START) {
248 _writeHeader(); 384 _writeHeader();
249 } 385 }
250 _outputStream = new _HttpOutputStream(this); 386 _outputStream = new _HttpOutputStream(this);
251 } 387 }
252 return _outputStream; 388 return _outputStream;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 _writeSP(); 492 _writeSP();
357 data = _statusCode.toString().charCodes(); 493 data = _statusCode.toString().charCodes();
358 _httpConnection._write(data); 494 _httpConnection._write(data);
359 _writeSP(); 495 _writeSP();
360 data = reasonPhrase.charCodes(); 496 data = reasonPhrase.charCodes();
361 _httpConnection._write(data); 497 _httpConnection._write(data);
362 _writeCRLF(); 498 _writeCRLF();
363 499
364 // Determine the value of the "Connection" header. 500 // Determine the value of the "Connection" header.
365 if (_protocolVersion == "1.1" && !_persistentConnection) { 501 if (_protocolVersion == "1.1" && !_persistentConnection) {
366 setHeader("Connection", "close"); 502 _headers.set("Connection", "close");
367 } else if (_protocolVersion == "1.0" && _persistentConnection) { 503 } else if (_protocolVersion == "1.0" && _persistentConnection) {
368 setHeader("Connection", "keep-alive"); 504 _headers.set("Connection", "keep-alive");
369 } 505 }
370 // Determine the value of the "Transfer-Encoding" header based on 506 // Determine the value of the "Transfer-Encoding" header based on
371 // whether the content length is known. 507 // whether the content length is known.
372 if (_contentLength >= 0) { 508 if (_contentLength >= 0) {
373 setHeader("Content-Length", _contentLength.toString()); 509 _headers.set("Content-Length", _contentLength.toString());
374 } else { 510 } else {
375 setHeader("Transfer-Encoding", "chunked"); 511 _headers.set("Transfer-Encoding", "chunked");
376 } 512 }
377 513
378 // Write headers. 514 // Write headers.
379 bool allWritten = _writeHeaders(); 515 bool allWritten = _writeHeaders();
380 _state = HEADERS_SENT; 516 _state = HEADERS_SENT;
381 return allWritten; 517 return allWritten;
382 } 518 }
383 519
384 // Response status code. 520 // Response status code.
385 int _statusCode; 521 int _statusCode;
386 String _reasonPhrase; 522 String _reasonPhrase;
387 String _protocolVersion; 523 String _protocolVersion;
388 Date _expires;
389 bool _persistentConnection; 524 bool _persistentConnection;
390 _HttpOutputStream _outputStream; 525 _HttpOutputStream _outputStream;
391 int _state; 526 int _state;
392 Function _streamErrorHandler; 527 Function _streamErrorHandler;
393 } 528 }
394 529
395 530
396 class _HttpInputStream extends _BaseDataInputStream implements InputStream { 531 class _HttpInputStream extends _BaseDataInputStream implements InputStream {
397 _HttpInputStream(_HttpRequestResponseBase this._requestOrResponse) { 532 _HttpInputStream(_HttpRequestResponseBase this._requestOrResponse) {
398 _checkScheduleCallbacks(); 533 _checkScheduleCallbacks();
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 _state = START { 861 _state = START {
727 _connection = connection; 862 _connection = connection;
728 // Default GET requests to have no content. 863 // Default GET requests to have no content.
729 if (_method == "GET") { 864 if (_method == "GET") {
730 _contentLength = 0; 865 _contentLength = 0;
731 } 866 }
732 } 867 }
733 868
734 void set contentLength(int contentLength) => _contentLength = contentLength; 869 void set contentLength(int contentLength) => _contentLength = contentLength;
735 870
736 String get host() => _host;
737 void set host(String host) {
738 _host = host;
739 _updateHostHeader();
740 }
741
742 int get port() => _port;
743 void set port(int port) {
744 _port = port;
745 _updateHostHeader();
746 }
747
748 void setHeader(String name, String value) {
749 if (_state != START) throw new HttpException("Header already sent");
750 if (name.toLowerCase() == "host") {
751 int pos = value.indexOf(":");
752 if (pos == -1) {
753 _host = value;
754 _port = HttpClient.DEFAULT_HTTP_PORT;
755 } else {
756 _host = value.substring(0, pos);
757 if (pos + 1 == value.length) {
758 _port = HttpClient.DEFAULT_HTTP_PORT;
759 } else {
760 _port = Math.parseInt(value.substring(pos + 1));
761 }
762 }
763 _updateHostHeader();
764 return;
765 }
766 _setHeader(name, value);
767 }
768
769 OutputStream get outputStream() { 871 OutputStream get outputStream() {
770 if (_state == DONE) throw new HttpException("Request closed"); 872 if (_state == DONE) throw new HttpException("Request closed");
771 if (_outputStream == null) { 873 if (_outputStream == null) {
772 // Ensure that headers are written. 874 // Ensure that headers are written.
773 if (_state == START) { 875 if (_state == START) {
774 _writeHeader(); 876 _writeHeader();
775 } 877 }
776 _outputStream = new _HttpOutputStream(this); 878 _outputStream = new _HttpOutputStream(this);
777 } 879 }
778 return _outputStream; 880 return _outputStream;
779 } 881 }
780 882
781 _updateHostHeader() {
782 String portPart = _port == HttpClient.DEFAULT_HTTP_PORT ? "" : ":$_port";
783 _setHeader("Host", "$host$portPart");
784 }
785
786 // Delegate functions for the HttpOutputStream implementation. 883 // Delegate functions for the HttpOutputStream implementation.
787 bool _streamWrite(List<int> buffer, bool copyBuffer) { 884 bool _streamWrite(List<int> buffer, bool copyBuffer) {
788 return _write(buffer, copyBuffer); 885 return _write(buffer, copyBuffer);
789 } 886 }
790 887
791 bool _streamWriteFrom(List<int> buffer, int offset, int len) { 888 bool _streamWriteFrom(List<int> buffer, int offset, int len) {
792 return _writeList(buffer, offset, len); 889 return _writeList(buffer, offset, len);
793 } 890 }
794 891
795 void _streamClose() { 892 void _streamClose() {
(...skipping 27 matching lines...) Expand all
823 _writeSP(); 920 _writeSP();
824 data = _uri.toString().charCodes(); 921 data = _uri.toString().charCodes();
825 _httpConnection._write(data); 922 _httpConnection._write(data);
826 _writeSP(); 923 _writeSP();
827 _httpConnection._write(_Const.HTTP11); 924 _httpConnection._write(_Const.HTTP11);
828 _writeCRLF(); 925 _writeCRLF();
829 926
830 // Determine the value of the "Transfer-Encoding" header based on 927 // Determine the value of the "Transfer-Encoding" header based on
831 // whether the content length is known. 928 // whether the content length is known.
832 if (_contentLength >= 0) { 929 if (_contentLength >= 0) {
833 setHeader("Content-Length", _contentLength.toString()); 930 _headers.set("Content-Length", _contentLength.toString());
834 } else { 931 } else {
835 setHeader("Transfer-Encoding", "chunked"); 932 _headers.set("Transfer-Encoding", "chunked");
836 } 933 }
837 934
838 // Write headers. 935 // Write headers.
839 _writeHeaders(); 936 _writeHeaders();
840 _state = HEADERS_SENT; 937 _state = HEADERS_SENT;
841 } 938 }
842 939
843 String _method; 940 String _method;
844 String _uri; 941 String _uri;
845 String _host;
846 int _port;
847 _HttpClientConnection _connection; 942 _HttpClientConnection _connection;
848 _HttpOutputStream _outputStream; 943 _HttpOutputStream _outputStream;
849 int _state; 944 int _state;
850 Function _streamErrorHandler; 945 Function _streamErrorHandler;
851 } 946 }
852 947
853 948
854 class _HttpClientResponse 949 class _HttpClientResponse
855 extends _HttpRequestResponseBase implements HttpClientResponse { 950 extends _HttpRequestResponseBase implements HttpClientResponse {
856 _HttpClientResponse(_HttpClientConnection connection) 951 _HttpClientResponse(_HttpClientConnection connection)
857 : super(connection) { 952 : super(connection) {
858 _connection = connection; 953 _connection = connection;
859 } 954 }
860 955
861 int get statusCode() => _statusCode; 956 int get statusCode() => _statusCode;
862 String get reasonPhrase() => _reasonPhrase; 957 String get reasonPhrase() => _reasonPhrase;
863 958
864 Date get expires() {
865 String str = _headers["expires"];
866 if (str == null) return null;
867 return _HttpUtils.parseDate(str);
868 }
869
870 Map get headers() => _headers;
871
872 InputStream get inputStream() { 959 InputStream get inputStream() {
873 if (_inputStream == null) { 960 if (_inputStream == null) {
874 _inputStream = new _HttpInputStream(this); 961 _inputStream = new _HttpInputStream(this);
875 } 962 }
876 return _inputStream; 963 return _inputStream;
877 } 964 }
878 965
879 void _onRequestStart(String method, String uri, String version) { 966 void _onRequestStart(String method, String uri, String version) {
880 // TODO(sgjesse): Error handling 967 // TODO(sgjesse): Error handling
881 } 968 }
882 969
883 void _onResponseStart(int statusCode, String reasonPhrase, String version) { 970 void _onResponseStart(int statusCode, String reasonPhrase, String version) {
884 _statusCode = statusCode; 971 _statusCode = statusCode;
885 _reasonPhrase = reasonPhrase; 972 _reasonPhrase = reasonPhrase;
886 } 973 }
887 974
888 void _onHeaderReceived(String name, String value) { 975 void _onHeaderReceived(String name, String value) {
889 _setHeader(name, value); 976 _headers.add(name, value);
890 } 977 }
891 978
892 void _onHeadersComplete() { 979 void _onHeadersComplete() {
893 _buffer = new _BufferList(); 980 _buffer = new _BufferList();
894 if (_connection._onResponse != null) { 981 if (_connection._onResponse != null) {
895 _connection._onResponse(this); 982 _connection._onResponse(this);
896 } 983 }
897 } 984 }
898 985
899 void _onDataReceived(List<int> data) { 986 void _onDataReceived(List<int> data) {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 return "$host:$port"; 1229 return "$host:$port";
1143 } 1230 }
1144 1231
1145 HttpClientConnection _prepareHttpClientConnection( 1232 HttpClientConnection _prepareHttpClientConnection(
1146 String host, int port, String method, String path) { 1233 String host, int port, String method, String path) {
1147 1234
1148 void _connectionOpened(_SocketConnection socketConn, 1235 void _connectionOpened(_SocketConnection socketConn,
1149 _HttpClientConnection connection) { 1236 _HttpClientConnection connection) {
1150 connection._connectionEstablished(socketConn); 1237 connection._connectionEstablished(socketConn);
1151 HttpClientRequest request = connection.open(method, path); 1238 HttpClientRequest request = connection.open(method, path);
1152 request.host = host; 1239 request.headers.host = host;
1153 request.port = port; 1240 request.headers.port = port;
1154 if (connection._onRequest != null) { 1241 if (connection._onRequest != null) {
1155 connection._onRequest(request); 1242 connection._onRequest(request);
1156 } else { 1243 } else {
1157 request.outputStream.close(); 1244 request.outputStream.close();
1158 } 1245 }
1159 } 1246 }
1160 1247
1161 _HttpClientConnection connection = new _HttpClientConnection(this); 1248 _HttpClientConnection connection = new _HttpClientConnection(this);
1162 1249
1163 // If there are active connections for this key get the first one 1250 // If there are active connections for this key get the first one
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 sockets.addFirst(socketConn); 1330 sockets.addFirst(socketConn);
1244 socketConn._markReturned(); 1331 socketConn._markReturned();
1245 } 1332 }
1246 1333
1247 Function _onOpen; 1334 Function _onOpen;
1248 Map<String, Queue<_SocketConnection>> _openSockets; 1335 Map<String, Queue<_SocketConnection>> _openSockets;
1249 Set<_SocketConnection> _activeSockets; 1336 Set<_SocketConnection> _activeSockets;
1250 Timer _evictionTimer; 1337 Timer _evictionTimer;
1251 bool _shutdown; // Has this HTTP client been shutdown? 1338 bool _shutdown; // Has this HTTP client been shutdown?
1252 } 1339 }
OLDNEW
« no previous file with comments | « runtime/bin/http.dart ('k') | runtime/bin/http_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698