| 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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 bool _streamWrite(List<int> buffer, bool copyBuffer) { | 1027 bool _streamWrite(List<int> buffer, bool copyBuffer) { |
| 1028 if (_done) throw new HttpException("Response closed"); | 1028 if (_done) throw new HttpException("Response closed"); |
| 1029 return _write(buffer, copyBuffer); | 1029 return _write(buffer, copyBuffer); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 bool _streamWriteFrom(List<int> buffer, int offset, int len) { | 1032 bool _streamWriteFrom(List<int> buffer, int offset, int len) { |
| 1033 if (_done) throw new HttpException("Response closed"); | 1033 if (_done) throw new HttpException("Response closed"); |
| 1034 return _writeList(buffer, offset, len); | 1034 return _writeList(buffer, offset, len); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 void _streamFlush() { |
| 1038 _httpConnection._flush(); |
| 1039 } |
| 1040 |
| 1037 void _streamClose() { | 1041 void _streamClose() { |
| 1038 _responseEnd(); | 1042 _responseEnd(); |
| 1039 } | 1043 } |
| 1040 | 1044 |
| 1041 void _streamSetNoPendingWriteHandler(callback()) { | 1045 void _streamSetNoPendingWriteHandler(callback()) { |
| 1042 if (_state != DONE) { | 1046 if (_state != DONE) { |
| 1043 _httpConnection._onNoPendingWrites = callback; | 1047 _httpConnection._onNoPendingWrites = callback; |
| 1044 } | 1048 } |
| 1045 } | 1049 } |
| 1046 | 1050 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 void set onError(void callback(e)) { | 1194 void set onError(void callback(e)) { |
| 1191 _requestOrResponse._streamSetErrorHandler(callback); | 1195 _requestOrResponse._streamSetErrorHandler(callback); |
| 1192 } | 1196 } |
| 1193 | 1197 |
| 1194 int _readInto(List<int> buffer, int offset, int len) { | 1198 int _readInto(List<int> buffer, int offset, int len) { |
| 1195 int result = _requestOrResponse._streamReadInto(buffer, offset, len); | 1199 int result = _requestOrResponse._streamReadInto(buffer, offset, len); |
| 1196 _checkScheduleCallbacks(); | 1200 _checkScheduleCallbacks(); |
| 1197 return result; | 1201 return result; |
| 1198 } | 1202 } |
| 1199 | 1203 |
| 1200 void flush() { | |
| 1201 // Nothing to do on a HTTP output stream. | |
| 1202 } | |
| 1203 | |
| 1204 void _close() { | 1204 void _close() { |
| 1205 // TODO(sgjesse): Handle this. | 1205 // TODO(sgjesse): Handle this. |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 void _dataReceived() { | 1208 void _dataReceived() { |
| 1209 super._dataReceived(); | 1209 super._dataReceived(); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 _HttpRequestResponseBase _requestOrResponse; | 1212 _HttpRequestResponseBase _requestOrResponse; |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 | 1215 |
| 1216 class _HttpOutputStream extends _BaseOutputStream implements OutputStream { | 1216 class _HttpOutputStream extends _BaseOutputStream implements OutputStream { |
| 1217 _HttpOutputStream(_HttpRequestResponseBase this._requestOrResponse); | 1217 _HttpOutputStream(_HttpRequestResponseBase this._requestOrResponse); |
| 1218 | 1218 |
| 1219 bool write(List<int> buffer, [bool copyBuffer = true]) { | 1219 bool write(List<int> buffer, [bool copyBuffer = true]) { |
| 1220 return _requestOrResponse._streamWrite(buffer, copyBuffer); | 1220 return _requestOrResponse._streamWrite(buffer, copyBuffer); |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 bool writeFrom(List<int> buffer, [int offset = 0, int len]) { | 1223 bool writeFrom(List<int> buffer, [int offset = 0, int len]) { |
| 1224 return _requestOrResponse._streamWriteFrom(buffer, offset, len); | 1224 return _requestOrResponse._streamWriteFrom(buffer, offset, len); |
| 1225 } | 1225 } |
| 1226 | 1226 |
| 1227 void flush() { |
| 1228 _requestOrResponse._streamFlush(); |
| 1229 } |
| 1230 |
| 1227 void close() { | 1231 void close() { |
| 1228 _requestOrResponse._streamClose(); | 1232 _requestOrResponse._streamClose(); |
| 1229 } | 1233 } |
| 1230 | 1234 |
| 1231 bool get closed => _requestOrResponse._done; | 1235 bool get closed => _requestOrResponse._done; |
| 1232 | 1236 |
| 1233 void destroy() { | 1237 void destroy() { |
| 1234 throw "Not implemented"; | 1238 throw "Not implemented"; |
| 1235 } | 1239 } |
| 1236 | 1240 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 return _socket.outputStream.write(data, copyBuffer); | 1276 return _socket.outputStream.write(data, copyBuffer); |
| 1273 } | 1277 } |
| 1274 } | 1278 } |
| 1275 | 1279 |
| 1276 bool _writeFrom(List<int> buffer, [int offset, int len]) { | 1280 bool _writeFrom(List<int> buffer, [int offset, int len]) { |
| 1277 if (!_error && !_closing) { | 1281 if (!_error && !_closing) { |
| 1278 return _socket.outputStream.writeFrom(buffer, offset, len); | 1282 return _socket.outputStream.writeFrom(buffer, offset, len); |
| 1279 } | 1283 } |
| 1280 } | 1284 } |
| 1281 | 1285 |
| 1286 bool _flush() { |
| 1287 _socket.outputStream.flush(); |
| 1288 } |
| 1289 |
| 1282 bool _close() { | 1290 bool _close() { |
| 1283 _closing = true; | 1291 _closing = true; |
| 1284 _socket.outputStream.close(); | 1292 _socket.outputStream.close(); |
| 1285 } | 1293 } |
| 1286 | 1294 |
| 1287 bool _destroy() { | 1295 bool _destroy() { |
| 1288 _closing = true; | 1296 _closing = true; |
| 1289 _socket.close(); | 1297 _socket.close(); |
| 1290 } | 1298 } |
| 1291 | 1299 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 bool _streamWrite(List<int> buffer, bool copyBuffer) { | 1648 bool _streamWrite(List<int> buffer, bool copyBuffer) { |
| 1641 if (_done) throw new HttpException("Request closed"); | 1649 if (_done) throw new HttpException("Request closed"); |
| 1642 return _write(buffer, copyBuffer); | 1650 return _write(buffer, copyBuffer); |
| 1643 } | 1651 } |
| 1644 | 1652 |
| 1645 bool _streamWriteFrom(List<int> buffer, int offset, int len) { | 1653 bool _streamWriteFrom(List<int> buffer, int offset, int len) { |
| 1646 if (_done) throw new HttpException("Request closed"); | 1654 if (_done) throw new HttpException("Request closed"); |
| 1647 return _writeList(buffer, offset, len); | 1655 return _writeList(buffer, offset, len); |
| 1648 } | 1656 } |
| 1649 | 1657 |
| 1658 void _streamFlush() { |
| 1659 _httpConnection._flush(); |
| 1660 } |
| 1661 |
| 1650 void _streamClose() { | 1662 void _streamClose() { |
| 1651 _ensureHeadersSent(); | 1663 _ensureHeadersSent(); |
| 1652 _state = DONE; | 1664 _state = DONE; |
| 1653 // Stop tracking no pending write events. | 1665 // Stop tracking no pending write events. |
| 1654 _httpConnection._onNoPendingWrites = null; | 1666 _httpConnection._onNoPendingWrites = null; |
| 1655 // Ensure that any trailing data is written. | 1667 // Ensure that any trailing data is written. |
| 1656 _writeDone(); | 1668 _writeDone(); |
| 1657 } | 1669 } |
| 1658 | 1670 |
| 1659 void _streamSetNoPendingWriteHandler(callback()) { | 1671 void _streamSetNoPendingWriteHandler(callback()) { |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2588 | 2600 |
| 2589 | 2601 |
| 2590 class _RedirectInfo implements RedirectInfo { | 2602 class _RedirectInfo implements RedirectInfo { |
| 2591 const _RedirectInfo(int this.statusCode, | 2603 const _RedirectInfo(int this.statusCode, |
| 2592 String this.method, | 2604 String this.method, |
| 2593 Uri this.location); | 2605 Uri this.location); |
| 2594 final int statusCode; | 2606 final int statusCode; |
| 2595 final String method; | 2607 final String method; |
| 2596 final Uri location; | 2608 final Uri location; |
| 2597 } | 2609 } |
| OLD | NEW |