OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/field_trial.h" | 10 #include "base/field_trial.h" |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 } else { | 880 } else { |
881 result = HandleSSLHandshakeError(result); | 881 result = HandleSSLHandshakeError(result); |
882 } | 882 } |
883 return result; | 883 return result; |
884 } | 884 } |
885 | 885 |
886 int HttpNetworkTransaction::DoSendRequest() { | 886 int HttpNetworkTransaction::DoSendRequest() { |
887 next_state_ = STATE_SEND_REQUEST_COMPLETE; | 887 next_state_ = STATE_SEND_REQUEST_COMPLETE; |
888 | 888 |
889 UploadDataStream* request_body = NULL; | 889 UploadDataStream* request_body = NULL; |
890 if (!establishing_tunnel_ && request_->upload_data) | 890 if (!establishing_tunnel_ && request_->upload_data) { |
891 request_body = new UploadDataStream(request_->upload_data); | 891 int error_code; |
| 892 request_body = UploadDataStream::Create(request_->upload_data, &error_code); |
| 893 if (!request_body) |
| 894 return error_code; |
| 895 } |
892 | 896 |
893 // This is constructed lazily (instead of within our Start method), so that | 897 // This is constructed lazily (instead of within our Start method), so that |
894 // we have proxy info available. | 898 // we have proxy info available. |
895 if (request_headers_.empty()) { | 899 if (request_headers_.empty()) { |
896 // Figure out if we can/should add Proxy-Authentication & Authentication | 900 // Figure out if we can/should add Proxy-Authentication & Authentication |
897 // headers. | 901 // headers. |
898 bool have_proxy_auth = | 902 bool have_proxy_auth = |
899 ShouldApplyProxyAuth() && | 903 ShouldApplyProxyAuth() && |
900 (HaveAuth(HttpAuth::AUTH_PROXY) || | 904 (HaveAuth(HttpAuth::AUTH_PROXY) || |
901 SelectPreemptiveAuth(HttpAuth::AUTH_PROXY)); | 905 SelectPreemptiveAuth(HttpAuth::AUTH_PROXY)); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 } else { | 1184 } else { |
1181 // SPDY is negotiated using the TLS next protocol negotiation (NPN) | 1185 // SPDY is negotiated using the TLS next protocol negotiation (NPN) |
1182 // extension, so |connection_| must contain an SSLClientSocket. | 1186 // extension, so |connection_| must contain an SSLClientSocket. |
1183 DCHECK(using_ssl_); | 1187 DCHECK(using_ssl_); |
1184 spdy_session = spdy_pool->GetSpdySessionFromSSLSocket( | 1188 spdy_session = spdy_pool->GetSpdySessionFromSSLSocket( |
1185 host_port_pair, session_, connection_.release()); | 1189 host_port_pair, session_, connection_.release()); |
1186 } | 1190 } |
1187 | 1191 |
1188 CHECK(spdy_session.get()); | 1192 CHECK(spdy_session.get()); |
1189 | 1193 |
1190 UploadDataStream* upload_data = request_->upload_data ? | 1194 UploadDataStream* upload_data = NULL; |
1191 new UploadDataStream(request_->upload_data) : NULL; | 1195 if (request_->upload_data) { |
| 1196 int error_code = OK; |
| 1197 upload_data = UploadDataStream::Create(request_->upload_data, &error_code); |
| 1198 if (!upload_data) |
| 1199 return error_code; |
| 1200 } |
1192 headers_valid_ = false; | 1201 headers_valid_ = false; |
1193 spdy_stream_ = spdy_session->GetOrCreateStream( | 1202 spdy_stream_ = spdy_session->GetOrCreateStream( |
1194 *request_, upload_data, net_log_); | 1203 *request_, upload_data, net_log_); |
1195 return spdy_stream_->SendRequest(upload_data, &response_, &io_callback_); | 1204 return spdy_stream_->SendRequest(upload_data, &response_, &io_callback_); |
1196 } | 1205 } |
1197 | 1206 |
1198 int HttpNetworkTransaction::DoSpdySendRequestComplete(int result) { | 1207 int HttpNetworkTransaction::DoSpdySendRequestComplete(int result) { |
1199 if (result < 0) | 1208 if (result < 0) |
1200 return result; | 1209 return result; |
1201 | 1210 |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 http_host_port_pair); | 1882 http_host_port_pair); |
1874 | 1883 |
1875 alternate_protocol_mode_ = kDoNotUseAlternateProtocol; | 1884 alternate_protocol_mode_ = kDoNotUseAlternateProtocol; |
1876 if (connection_->socket()) | 1885 if (connection_->socket()) |
1877 connection_->socket()->Disconnect(); | 1886 connection_->socket()->Disconnect(); |
1878 connection_->Reset(); | 1887 connection_->Reset(); |
1879 next_state_ = STATE_INIT_CONNECTION; | 1888 next_state_ = STATE_INIT_CONNECTION; |
1880 } | 1889 } |
1881 | 1890 |
1882 } // namespace net | 1891 } // namespace net |
OLD | NEW |