Index: sdk/lib/io/http_impl.dart |
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart |
index b586f0974463c417c159ace7a534484078e05322..bbde502f59cff9d55b1af99992c7012466849ee7 100644 |
--- a/sdk/lib/io/http_impl.dart |
+++ b/sdk/lib/io/http_impl.dart |
@@ -538,11 +538,11 @@ abstract class _HttpOutboundMessage<T> implements IOSink { |
headers.chunkedTransferEncoding = false; |
headers.contentLength = 0; |
} else if (!_ignoreBody && headers.contentLength > 0) { |
- _headersSink.close().catchError((_) {}); |
- return new Future.error(new HttpException( |
+ _headersSink.addError(new HttpException( |
"No content while contentLength was specified to be greater " |
- " than 0: ${headers.contentLength}.", |
+ "than 0: ${headers.contentLength}.", |
uri: _uri)); |
+ return _headersSink.done; |
} |
} |
return _writeHeaders().then((_) => _headersSink.close()); |
@@ -620,11 +620,9 @@ class _HttpOutboundConsumer implements StreamConsumer { |
} |
_completer = new Completer(); |
_subscription = stream.listen( |
- (data) { |
- _controller.add(data); |
- }, |
+ (data) => _controller.add(data), |
onDone: _done, |
- onError: _done, |
+ onError: (e) => _controller.addError(e), |
Søren Gjesse
2013/10/23 08:14:05
Do we want to propagate the stack trace here?
Anders Johnsen
2013/10/23 10:23:24
Yes, nice catch! :)
|
cancelOnError: true); |
// Pause the first request. |
if (_controller == null) _subscription.pause(); |
@@ -1878,7 +1876,8 @@ class _HttpConnection extends LinkedListEntry<_HttpConnection> { |
if (_state == _DETACHED) return; |
if (response.persistentConnection && |
request.persistentConnection && |
- incoming.fullBodyRead) { |
+ incoming.fullBodyRead && |
+ !_httpParser.upgrade) { |
_state = _IDLE; |
_startTimeout(); |
// Resume the subscription for incoming requests as the |
@@ -1895,7 +1894,7 @@ class _HttpConnection extends LinkedListEntry<_HttpConnection> { |
}); |
response._ignoreBody = request.method == "HEAD"; |
response._httpRequest = request; |
- _httpServer._handleRequest(request); |
+ _httpServer._handleRequest(request, this); |
}, |
onDone: () { |
destroy(); |
@@ -2015,15 +2014,17 @@ class _HttpServer extends Stream<HttpRequest> implements HttpServer { |
} else { |
result = new Future.value(); |
} |
- if (_sessionManagerInstance != null) { |
+ _maybeCloseSessionManager(); |
+ return result; |
+ } |
+ |
+ void _maybeCloseSessionManager() { |
+ if (closed && |
+ _connections.length == 0 && |
+ _sessionManagerInstance != null) { |
_sessionManagerInstance.close(); |
_sessionManagerInstance = null; |
} |
- for (_HttpConnection connection in _connections.toList()) { |
- connection.destroy(); |
- } |
- _connections.clear(); |
- return result; |
} |
int get port { |
@@ -2040,7 +2041,11 @@ class _HttpServer extends Stream<HttpRequest> implements HttpServer { |
_sessionManager.sessionTimeout = timeout; |
} |
- void _handleRequest(HttpRequest request) { |
+ void _handleRequest(HttpRequest request, _HttpConnection connection) { |
+ if (closed) { |
+ connection.destroy(); |
+ return; |
+ } |
_controller.add(request); |
} |
@@ -2050,6 +2055,7 @@ class _HttpServer extends Stream<HttpRequest> implements HttpServer { |
void _connectionClosed(_HttpConnection connection) { |
_connections.remove(connection); |
+ _maybeCloseSessionManager(); |
} |
_HttpSessionManager get _sessionManager { |
@@ -2176,7 +2182,7 @@ class _HttpConnectionInfo implements HttpConnectionInfo { |
static _HttpConnectionInfo create(Socket socket) { |
if (socket == null) return null; |
try { |
- _HttpConnectionInfo info = new _HttpConnectionInfo._(); |
+ _HttpConnectionInfo info = new _HttpConnectionInfo(); |
info.remoteHost = socket.remoteHost; |
info.remotePort = socket.remotePort; |
info.localPort = socket.port; |
@@ -2185,8 +2191,6 @@ class _HttpConnectionInfo implements HttpConnectionInfo { |
return null; |
} |
- _HttpConnectionInfo._(); |
- |
String remoteHost; |
int remotePort; |
int localPort; |