summaryrefslogtreecommitdiffstats
path: root/net/http/http_stream_parser.cc
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-19 05:56:38 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-19 05:56:38 +0000
commit8e6441caa3adedf373b8ff80bb1fb48caff81556 (patch)
tree4a37d2fe5aaa3aad04b01171feb04e329c7e0383 /net/http/http_stream_parser.cc
parent33f275a2e2e703c58f514af8efe963e2e29792f9 (diff)
downloadchromium_src-8e6441caa3adedf373b8ff80bb1fb48caff81556.zip
chromium_src-8e6441caa3adedf373b8ff80bb1fb48caff81556.tar.gz
chromium_src-8e6441caa3adedf373b8ff80bb1fb48caff81556.tar.bz2
Extract connection logic from HttpNetworkTransaction into a new
HttpStreamFactory. The HttpNetworkTransaction now deals exclusively with streams rather than connections directly. This cut the size of HTN roughly in in half. The HttpNetworkTransaction is still responsible for all proxy and server authentication functions. This is because the streams may come and go - we could create a stream, have the server declare auth is needed, and then the next attempt would be on a different stream. So Auth belongs on the HNT. The HNT no longer has direct access to the connection itself; instead, it only knows of an HttpStream. The StreamRequest, however, is responsible for determining whether the connection needs to use a proxy, whether AlternateProtocols are available, and whether the connection should be SPDY or HTTP. Other changes: - moved some static configuration methods from HNT to HttpStreamFactory. - added some methods to the HttpStream. BUG=none TEST=all Review URL: http://codereview.chromium.org/3171002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_stream_parser.cc')
-rw-r--r--net/http/http_stream_parser.cc42
1 files changed, 41 insertions, 1 deletions
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 68f98b9..5fbcb5b 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -12,6 +12,7 @@
#include "net/http/http_request_info.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
+#include "net/socket/ssl_client_socket.h"
#include "net/socket/client_socket_handle.h"
namespace net {
@@ -93,6 +94,12 @@ int HttpStreamParser::ReadResponseHeaders(CompletionCallback* callback) {
return result > 0 ? OK : result;
}
+void HttpStreamParser::Close(bool not_reusable) {
+ if (not_reusable && connection_->socket())
+ connection_->socket()->Disconnect();
+ connection_->Reset();
+}
+
int HttpStreamParser::ReadResponseBody(IOBuffer* buf, int buf_len,
CompletionCallback* callback) {
DCHECK(io_state_ == STATE_BODY_PENDING || io_state_ == STATE_DONE);
@@ -266,8 +273,10 @@ int HttpStreamParser::DoReadHeadersComplete(int result) {
io_state_ = STATE_DONE;
return result;
}
+ // If we've used the connection before, then we know it is not a HTTP/0.9
+ // response and return ERR_CONNECTION_CLOSED.
if (result == ERR_CONNECTION_CLOSED && read_buf_->offset() == 0 &&
- connection_->ShouldResendFailedRequest(result)) {
+ connection_->is_reused()) {
io_state_ = STATE_DONE;
return result;
}
@@ -558,4 +567,35 @@ bool HttpStreamParser::IsMoreDataBuffered() const {
return read_buf_->offset() > read_buf_unused_offset_;
}
+bool HttpStreamParser::IsConnectionReused() const {
+ ClientSocketHandle::SocketReuseType reuse_type = connection_->reuse_type();
+ return connection_->is_reused() ||
+ reuse_type == ClientSocketHandle::UNUSED_IDLE;
+}
+
+void HttpStreamParser::SetConnectionReused() {
+ connection_->set_is_reused(true);
+}
+
+void HttpStreamParser::GetSSLInfo(SSLInfo* ssl_info) {
+ if (request_->url.SchemeIs("https")) {
+ CHECK(connection_->socket()->IsConnected());
+ SSLClientSocket* ssl_socket =
+ static_cast<SSLClientSocket*>(connection_->socket());
+ ssl_socket->GetSSLInfo(ssl_info);
+ }
+}
+
+void HttpStreamParser::GetSSLCertRequestInfo(
+ SSLCertRequestInfo* cert_request_info) {
+ if (request_->url.SchemeIs("https")) {
+ if (!connection_->socket() || !connection_->socket()->IsConnected())
+ return;
+ CHECK(connection_->socket()->IsConnected());
+ SSLClientSocket* ssl_socket =
+ static_cast<SSLClientSocket*>(connection_->socket());
+ ssl_socket->GetSSLCertRequestInfo(cert_request_info);
+ }
+}
+
} // namespace net