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

Unified Diff: sdk/lib/io/http_impl.dart

Issue 11316080: Change the HTTP close handling (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/io/http_parser.dart » ('j') | sdk/lib/io/http_parser.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 5c4387e42cf93aee79508b36836eaab4b7ea2dc1..e225cc66ff5f69cc188d4f33edfab8cfe10ca387 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -11,16 +11,17 @@ class _CloseQueue {
void add(_HttpConnectionBase connection) {
void closeIfDone() {
- // We only check for write closed here. This means that we are
- // not waiting for the client to half-close the socket before
- // fully closing the socket.
- if (!connection._isWriteClosed) return;
+ // When either the client has closed or all data has been
+ // written to the client we close the underlying socket
+ // completely.
+ if (!connection._isWriteClosed && !connection._isReadClosed) return;
Mads Ager (google) 2012/11/20 08:04:28 Maybe remove the negations and make this: if (con
Søren Gjesse 2012/11/20 08:15:11 Much better, done.
_q.remove(connection);
connection._socket.close();
if (connection.onClosed != null) connection.onClosed();
}
- // If the connection is already fully closed don't insert it into the queue.
+ // If the connection is already fully closed don't insert it into
+ // the queue.
if (connection._isFullyClosed) {
connection._socket.close();
if (connection.onClosed != null) connection.onClosed();
@@ -46,10 +47,6 @@ class _CloseQueue {
if (!connection._isReadClosed) {
connection._socket.onClosed = () {
connection._state |= _HttpConnectionBase.READ_CLOSED;
- // This is a nop, as we are not using the read closed
- // information for anything. For both server and client
- // connections the inbound message have been read to
- // completion when the socket enters the close queue.
closeIfDone();
};
} else {
@@ -61,6 +58,7 @@ class _CloseQueue {
// If an error occurs immediately close the socket.
connection._socket.onError = (e) {
+ connection._state |= _HttpConnectionBase.READ_CLOSED;
connection._state |= _HttpConnectionBase.WRITE_CLOSED;
closeIfDone();
};
@@ -876,24 +874,24 @@ class _HttpConnection extends _HttpConnectionBase {
}
void _checkDone() {
- if (_isAllDone) {
- // If we are done writing the response, and either the client
- // has closed or the connection is not persistent, we must
- // close. Also if using HTTP 1.0 and the content length was not
- // known we must close to indicate end of body.
+ if (_isReadClosed) {
+ // If the client closes the conversation is ended.
+ _server._closeQueue.add(this);
+ } else if (_isAllDone) {
+ // If we are done writing the response, and the connection is
+ // not persistent, we must close. Also if using HTTP 1.0 and the
+ // content length was not known we must close to indicate end of
+ // body.
bool close =
!_response.persistentConnection ||
(_response._protocolVersion == "1.0" && _response._contentLength < 0);
_request = null;
_response = null;
- if (_isReadClosed || close) {
+ if (close) {
_server._closeQueue.add(this);
} else {
_state = _HttpConnectionBase.IDLE;
}
- } else if (_state == _HttpConnectionBase.READ_CLOSED) {
- // If entering READ_CLOSED state while idle close the connection.
- _server._closeQueue.add(this);
}
}
« no previous file with comments | « no previous file | sdk/lib/io/http_parser.dart » ('j') | sdk/lib/io/http_parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698