OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 // The close queue handles graceful closing of HTTP connections. When | 7 // The close queue handles graceful closing of HTTP connections. When |
8 // a connection is added to the queue it will enter a wait state | 8 // a connection is added to the queue it will enter a wait state |
9 // waiting for all data written and possibly socket shutdown from | 9 // waiting for all data written and possibly socket shutdown from |
10 // peer. | 10 // peer. |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 bool _writeHeader() { | 578 bool _writeHeader() { |
579 List<int> data; | 579 List<int> data; |
580 | 580 |
581 // Write status line. | 581 // Write status line. |
582 if (_protocolVersion == "1.1") { | 582 if (_protocolVersion == "1.1") { |
583 _httpConnection._write(_Const.HTTP11); | 583 _httpConnection._write(_Const.HTTP11); |
584 } else { | 584 } else { |
585 _httpConnection._write(_Const.HTTP10); | 585 _httpConnection._write(_Const.HTTP10); |
586 } | 586 } |
587 _writeSP(); | 587 _writeSP(); |
588 data = _statusCode.toString().charCodes; | 588 data = _statusCode.toString().codeUnits; |
589 _httpConnection._write(data); | 589 _httpConnection._write(data); |
590 _writeSP(); | 590 _writeSP(); |
591 data = reasonPhrase.charCodes; | 591 data = reasonPhrase.codeUnits; |
592 _httpConnection._write(data); | 592 _httpConnection._write(data); |
593 _writeCRLF(); | 593 _writeCRLF(); |
594 | 594 |
595 var session = _httpConnection._request._session; | 595 var session = _httpConnection._request._session; |
596 if (session != null && !session._destroyed) { | 596 if (session != null && !session._destroyed) { |
597 // Make sure we only send the current session id. | 597 // Make sure we only send the current session id. |
598 bool found = false; | 598 bool found = false; |
599 for (int i = 0; i < cookies.length; i++) { | 599 for (int i = 0; i < cookies.length; i++) { |
600 if (cookies[i].name.toUpperCase() == _DART_SESSION_ID) { | 600 if (cookies[i].name.toUpperCase() == _DART_SESSION_ID) { |
601 cookies[i].value = session.id; | 601 cookies[i].value = session.id; |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 } | 1228 } |
1229 | 1229 |
1230 void _streamSetErrorHandler(callback(e)) { | 1230 void _streamSetErrorHandler(callback(e)) { |
1231 _streamErrorHandler = callback; | 1231 _streamErrorHandler = callback; |
1232 } | 1232 } |
1233 | 1233 |
1234 void _writeHeader() { | 1234 void _writeHeader() { |
1235 List<int> data; | 1235 List<int> data; |
1236 | 1236 |
1237 // Write request line. | 1237 // Write request line. |
1238 data = _method.toString().charCodes; | 1238 data = _method.toString().codeUnits; |
1239 _httpConnection._write(data); | 1239 _httpConnection._write(data); |
1240 _writeSP(); | 1240 _writeSP(); |
1241 // Send the path for direct connections and the whole URL for | 1241 // Send the path for direct connections and the whole URL for |
1242 // proxy connections. | 1242 // proxy connections. |
1243 if (!_connection._usingProxy) { | 1243 if (!_connection._usingProxy) { |
1244 String path = _uri.path; | 1244 String path = _uri.path; |
1245 if (path.length == 0) path = "/"; | 1245 if (path.length == 0) path = "/"; |
1246 if (_uri.query != "") { | 1246 if (_uri.query != "") { |
1247 if (_uri.fragment != "") { | 1247 if (_uri.fragment != "") { |
1248 path = "${path}?${_uri.query}#${_uri.fragment}"; | 1248 path = "${path}?${_uri.query}#${_uri.fragment}"; |
1249 } else { | 1249 } else { |
1250 path = "${path}?${_uri.query}"; | 1250 path = "${path}?${_uri.query}"; |
1251 } | 1251 } |
1252 } | 1252 } |
1253 data = path.charCodes; | 1253 data = path.codeUnits; |
1254 } else { | 1254 } else { |
1255 data = _uri.toString().charCodes; | 1255 data = _uri.toString().codeUnits; |
1256 } | 1256 } |
1257 _httpConnection._write(data); | 1257 _httpConnection._write(data); |
1258 _writeSP(); | 1258 _writeSP(); |
1259 _httpConnection._write(_Const.HTTP11); | 1259 _httpConnection._write(_Const.HTTP11); |
1260 _writeCRLF(); | 1260 _writeCRLF(); |
1261 | 1261 |
1262 // Add the cookies to the headers. | 1262 // Add the cookies to the headers. |
1263 if (_cookies != null) { | 1263 if (_cookies != null) { |
1264 StringBuffer sb = new StringBuffer(); | 1264 StringBuffer sb = new StringBuffer(); |
1265 for (int i = 0; i < _cookies.length; i++) { | 1265 for (int i = 0; i < _cookies.length; i++) { |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 | 2330 |
2331 | 2331 |
2332 class _RedirectInfo implements RedirectInfo { | 2332 class _RedirectInfo implements RedirectInfo { |
2333 const _RedirectInfo(int this.statusCode, | 2333 const _RedirectInfo(int this.statusCode, |
2334 String this.method, | 2334 String this.method, |
2335 Uri this.location); | 2335 Uri this.location); |
2336 final int statusCode; | 2336 final int statusCode; |
2337 final String method; | 2337 final String method; |
2338 final Uri location; | 2338 final Uri location; |
2339 } | 2339 } |
OLD | NEW |