summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 21:28:14 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 21:28:14 +0000
commit02c92c499441303f58312463b30deb53f02dba63 (patch)
tree26c3cae25835fe74e176c625c67333106ec780f6 /net
parent4bf413576fa9c6e19a16119b007112f7a32c6ffc (diff)
downloadchromium_src-02c92c499441303f58312463b30deb53f02dba63.zip
chromium_src-02c92c499441303f58312463b30deb53f02dba63.tar.gz
chromium_src-02c92c499441303f58312463b30deb53f02dba63.tar.bz2
Use 0 for successful end of stream.
BUG=25032 TEST=none Review URL: http://codereview.chromium.org/669122 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/net_error_list.h3
-rw-r--r--net/http/http_network_transaction.cc15
-rw-r--r--net/http/http_stream.h4
-rw-r--r--net/http/http_stream_parser.cc10
4 files changed, 13 insertions, 19 deletions
diff --git a/net/base/net_error_list.h b/net/base/net_error_list.h
index 4030379..9c83568 100644
--- a/net/base/net_error_list.h
+++ b/net/base/net_error_list.h
@@ -134,8 +134,7 @@ NET_ERROR(SOCKS_CONNECTION_FAILED, -120)
// because that host is unreachable.
NET_ERROR(SOCKS_CONNECTION_HOST_UNREACHABLE, -121)
-// There is no more data left in the logical stream.
-NET_ERROR(END_OF_STREAM, -122)
+// Error number -122 is available for use.
// The peer sent an SSL no_renegotiation alert message.
NET_ERROR(SSL_NO_RENEGOTIATION, -123)
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 2e4f911..d42dcda 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -951,7 +951,7 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) {
}
if (result == ERR_CONNECTION_CLOSED) {
- // For now, if we get at last some data, we do the best we can to make
+ // For now, if we get at least some data, we do the best we can to make
// sense of it and send it back up the stack.
int rv = HandleConnectionClosedBeforeEndOfHeaders();
if (rv != OK)
@@ -1049,22 +1049,13 @@ int HttpNetworkTransaction::DoReadBodyComplete(int result) {
"We should never read a response body of a tunnel.";
bool done = false, keep_alive = false;
- if (result < 0) {
- // Error or closed connection while reading the socket.
+ if (result <= 0)
done = true;
- // TODO(wtc): Traditionally this code has returned 0 when reading a closed
- // socket. That is partially corrected in classes that we call, but
- // callers need to be updated.
- if (result == ERR_END_OF_STREAM || (!http_stream_->CanFindEndOfResponse() &&
- result == ERR_CONNECTION_CLOSED)) {
- result = 0;
- }
- }
if (http_stream_->IsResponseBodyComplete()) {
done = true;
if (http_stream_->CanFindEndOfResponse())
- keep_alive = GetResponseHeaders()->IsKeepAlive();
+ keep_alive = GetResponseHeaders()->IsKeepAlive();
}
// Clean up connection_->if we are done.
diff --git a/net/http/http_stream.h b/net/http/http_stream.h
index 978ebdb..87bd8e2 100644
--- a/net/http/http_stream.h
+++ b/net/http/http_stream.h
@@ -53,8 +53,8 @@ class HttpStream {
// Reads response body data, up to |buf_len| bytes. |buf_len| should be a
// reasonable size (<2MB). The number of bytes read is returned, or an
- // error is returned upon failure. ERR_END_OF_STREAM indicates that the
- // request has been fully satisfied and there is no more data to read.
+ // error is returned upon failure. 0 indicates that the request has been
+ // fully satisfied and there is no more data to read.
// ERR_CONNECTION_CLOSED is returned when the connection has been closed
// prematurely. ERR_IO_PENDING is returned if the operation could not be
// completed synchronously, in which case the result will be passed to the
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 0a635f5..446c8ed 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -353,7 +353,7 @@ int HttpStreamParser::DoReadBody() {
// Check to see if we're done reading.
if (IsResponseBodyComplete())
- return ERR_END_OF_STREAM;
+ return 0;
DCHECK_EQ(0, read_buf_->offset());
return connection_->socket()->Read(user_read_buf_, user_read_buf_len_,
@@ -361,7 +361,11 @@ int HttpStreamParser::DoReadBody() {
}
int HttpStreamParser::DoReadBodyComplete(int result) {
- if (result == 0)
+ // If we didn't get a content-length and aren't using a chunked encoding,
+ // the only way to signal the end of a stream is to close the connection,
+ // so we don't treat that as an error, though in some cases we may not
+ // have completely received the resource.
+ if (result == 0 && !IsResponseBodyComplete() && CanFindEndOfResponse())
result = ERR_CONNECTION_CLOSED;
// Filter incoming data if appropriate. FilterBuf may return an error.
@@ -378,7 +382,7 @@ int HttpStreamParser::DoReadBodyComplete(int result) {
if (result > 0)
response_body_read_ += result;
- if (result < 0 || IsResponseBodyComplete()) {
+ if (result <= 0 || IsResponseBodyComplete()) {
io_state_ = STATE_DONE;
// Save the overflow data, which can be in two places. There may be