| 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 class _HttpIncoming extends Stream<List<int>> { | 7 class _HttpIncoming extends Stream<List<int>> { |
| 8 final int _transferLength; | 8 final int _transferLength; |
| 9 final Completer _dataCompleter = new Completer(); | 9 final Completer _dataCompleter = new Completer(); |
| 10 Stream<List<int>> _stream; | 10 Stream<List<int>> _stream; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 bool cancelOnError}) { | 40 bool cancelOnError}) { |
| 41 return _stream.listen(onData, | 41 return _stream.listen(onData, |
| 42 onError: onError, | 42 onError: onError, |
| 43 onDone: onDone, | 43 onDone: onDone, |
| 44 cancelOnError: cancelOnError); | 44 cancelOnError: cancelOnError); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Is completed once all data have been received. | 47 // Is completed once all data have been received. |
| 48 Future get dataDone => _dataCompleter.future; | 48 Future get dataDone => _dataCompleter.future; |
| 49 | 49 |
| 50 void close() { | 50 void close(bool closing) { |
| 51 fullBodyRead = true; | 51 fullBodyRead = true; |
| 52 _dataCompleter.complete(); | 52 _dataCompleter.complete(closing); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 abstract class _HttpInboundMessage extends Stream<List<int>> { | 56 abstract class _HttpInboundMessage extends Stream<List<int>> { |
| 57 final _HttpIncoming _incoming; | 57 final _HttpIncoming _incoming; |
| 58 List<Cookie> _cookies; | 58 List<Cookie> _cookies; |
| 59 | 59 |
| 60 _HttpInboundMessage(_HttpIncoming this._incoming); | 60 _HttpInboundMessage(_HttpIncoming this._incoming); |
| 61 | 61 |
| 62 List<Cookie> get cookies { | 62 List<Cookie> get cookies { |
| (...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1661 final _HttpParser _httpParser; | 1661 final _HttpParser _httpParser; |
| 1662 StreamSubscription _subscription; | 1662 StreamSubscription _subscription; |
| 1663 | 1663 |
| 1664 Future _streamFuture; | 1664 Future _streamFuture; |
| 1665 | 1665 |
| 1666 _HttpConnection(Socket this._socket, _HttpServer this._httpServer) | 1666 _HttpConnection(Socket this._socket, _HttpServer this._httpServer) |
| 1667 : _httpParser = new _HttpParser.requestParser() { | 1667 : _httpParser = new _HttpParser.requestParser() { |
| 1668 _socket.pipe(_httpParser); | 1668 _socket.pipe(_httpParser); |
| 1669 _subscription = _httpParser.listen( | 1669 _subscription = _httpParser.listen( |
| 1670 (incoming) { | 1670 (incoming) { |
| 1671 // If the incoming was closed, close the connection. |
| 1672 incoming.dataDone.then((closing) { |
| 1673 if (closing) destroy(); |
| 1674 }); |
| 1671 // Only handle one incoming request at the time. Keep the | 1675 // Only handle one incoming request at the time. Keep the |
| 1672 // stream paused until the request has been send. | 1676 // stream paused until the request has been send. |
| 1673 _subscription.pause(); | 1677 _subscription.pause(); |
| 1674 _state = _ACTIVE; | 1678 _state = _ACTIVE; |
| 1675 var outgoing = new _HttpOutgoing(_socket); | 1679 var outgoing = new _HttpOutgoing(_socket); |
| 1676 var response = new _HttpResponse(incoming.headers.protocolVersion, | 1680 var response = new _HttpResponse(incoming.headers.protocolVersion, |
| 1677 outgoing); | 1681 outgoing); |
| 1678 var request = new _HttpRequest(response, incoming, _httpServer, this); | 1682 var request = new _HttpRequest(response, incoming, _httpServer, this); |
| 1679 _streamFuture = outgoing.done | 1683 _streamFuture = outgoing.done |
| 1680 .then((_) { | 1684 .then((_) { |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 | 2260 |
| 2257 | 2261 |
| 2258 class _RedirectInfo implements RedirectInfo { | 2262 class _RedirectInfo implements RedirectInfo { |
| 2259 const _RedirectInfo(int this.statusCode, | 2263 const _RedirectInfo(int this.statusCode, |
| 2260 String this.method, | 2264 String this.method, |
| 2261 Uri this.location); | 2265 Uri this.location); |
| 2262 final int statusCode; | 2266 final int statusCode; |
| 2263 final String method; | 2267 final String method; |
| 2264 final Uri location; | 2268 final Uri location; |
| 2265 } | 2269 } |
| OLD | NEW |