Index: net/http/http_network_transaction.cc |
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc |
index fcad53aee56f59e5e6277afcc60357c6acabdbd7..39da7de1a709d032e62d220f6b1a659553b90afc 100644 |
--- a/net/http/http_network_transaction.cc |
+++ b/net/http/http_network_transaction.cc |
@@ -129,7 +129,8 @@ HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority, |
request_headers_(), |
read_buf_len_(0), |
next_state_(STATE_NONE), |
- establishing_tunnel_(false) { |
+ establishing_tunnel_(false), |
+ websocket_handshake_stream_base_factory_(NULL) { |
session->ssl_config_service()->GetSSLConfig(&server_ssl_config_); |
if (session->http_stream_factory()->has_next_protos()) { |
server_ssl_config_.next_protos = |
@@ -429,6 +430,11 @@ void HttpNetworkTransaction::SetPriority(RequestPriority priority) { |
stream_->SetPriority(priority); |
} |
+void HttpNetworkTransaction::SetWebSocketHandshakeStreamFactory( |
+ WebSocketHandshakeStreamBase::Factory* factory) { |
+ websocket_handshake_stream_base_factory_ = factory; |
+} |
+ |
void HttpNetworkTransaction::OnStreamReady(const SSLConfig& used_ssl_config, |
const ProxyInfo& used_proxy_info, |
HttpStreamBase* stream) { |
@@ -451,7 +457,7 @@ void HttpNetworkTransaction::OnWebSocketHandshakeStreamReady( |
const SSLConfig& used_ssl_config, |
const ProxyInfo& used_proxy_info, |
WebSocketHandshakeStreamBase* stream) { |
- NOTREACHED() << "This function should never be called."; |
+ OnStreamReady(used_ssl_config, used_proxy_info, stream); |
} |
void HttpNetworkTransaction::OnStreamFailed(int result, |
@@ -657,14 +663,27 @@ int HttpNetworkTransaction::DoLoop(int result) { |
int HttpNetworkTransaction::DoCreateStream() { |
next_state_ = STATE_CREATE_STREAM_COMPLETE; |
- stream_request_.reset( |
- session_->http_stream_factory()->RequestStream( |
- *request_, |
- priority_, |
- server_ssl_config_, |
- proxy_ssl_config_, |
- this, |
- net_log_)); |
+ if (websocket_handshake_stream_base_factory_ && |
+ (request_->url.SchemeIs("ws") || request_->url.SchemeIs("wss"))) { |
+ stream_request_.reset(session_->websocket_handshake_stream_factory() |
+ ->RequestWebSocketHandshakeStream( |
+ *request_, |
+ priority_, |
+ server_ssl_config_, |
+ proxy_ssl_config_, |
+ this, |
+ websocket_handshake_stream_base_factory_, |
+ net_log_)); |
+ } else { |
+ stream_request_.reset( |
+ session_->http_stream_factory()->RequestStream( |
+ *request_, |
+ priority_, |
+ server_ssl_config_, |
+ proxy_ssl_config_, |
+ this, |
+ net_log_)); |
+ } |
DCHECK(stream_request_.get()); |
return ERR_IO_PENDING; |
} |
@@ -989,7 +1008,9 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) { |
// need to skip over it. |
// We treat any other 1xx in this same way (although in practice getting |
// a 1xx that isn't a 100 is rare). |
- if (response_.headers->response_code() / 100 == 1) { |
+ // Unless this is a WebSocket request, in which case we pass it on up. |
+ if (response_.headers->response_code() / 100 == 1 && |
+ !websocket_handshake_stream_base_factory_) { |
yhirano
2013/11/06 05:00:05
Code in DoCreateStream does:
if websocket_handsh
Adam Rice
2013/11/07 01:45:22
I tried factoring out the code into a ForWebSocket
|
response_.headers = new HttpResponseHeaders(std::string()); |
next_state_ = STATE_READ_HEADERS; |
return OK; |