OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "net/http/http_auth_handler.h" | 32 #include "net/http/http_auth_handler.h" |
33 #include "net/http/http_auth_handler_factory.h" | 33 #include "net/http/http_auth_handler_factory.h" |
34 #include "net/http/http_basic_stream.h" | 34 #include "net/http/http_basic_stream.h" |
35 #include "net/http/http_chunked_decoder.h" | 35 #include "net/http/http_chunked_decoder.h" |
36 #include "net/http/http_net_log_params.h" | 36 #include "net/http/http_net_log_params.h" |
37 #include "net/http/http_network_session.h" | 37 #include "net/http/http_network_session.h" |
38 #include "net/http/http_proxy_client_socket.h" | 38 #include "net/http/http_proxy_client_socket.h" |
39 #include "net/http/http_proxy_client_socket_pool.h" | 39 #include "net/http/http_proxy_client_socket_pool.h" |
40 #include "net/http/http_request_headers.h" | 40 #include "net/http/http_request_headers.h" |
41 #include "net/http/http_request_info.h" | 41 #include "net/http/http_request_info.h" |
42 #include "net/http/http_response_body_drainer.h" | |
43 #include "net/http/http_response_headers.h" | 42 #include "net/http/http_response_headers.h" |
44 #include "net/http/http_response_info.h" | 43 #include "net/http/http_response_info.h" |
45 #include "net/http/http_server_properties.h" | 44 #include "net/http/http_server_properties.h" |
46 #include "net/http/http_stream_factory.h" | 45 #include "net/http/http_stream_factory.h" |
47 #include "net/http/http_util.h" | 46 #include "net/http/http_util.h" |
48 #include "net/http/url_security_manager.h" | 47 #include "net/http/url_security_manager.h" |
49 #include "net/socket/client_socket_factory.h" | 48 #include "net/socket/client_socket_factory.h" |
50 #include "net/socket/socks_client_socket_pool.h" | 49 #include "net/socket/socks_client_socket_pool.h" |
51 #include "net/socket/ssl_client_socket.h" | 50 #include "net/socket/ssl_client_socket.h" |
52 #include "net/socket/ssl_client_socket_pool.h" | 51 #include "net/socket/ssl_client_socket_pool.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 stream_->Close(true /* not reusable */); | 129 stream_->Close(true /* not reusable */); |
131 } else { | 130 } else { |
132 if (stream_->IsResponseBodyComplete()) { | 131 if (stream_->IsResponseBodyComplete()) { |
133 // If the response body is complete, we can just reuse the socket. | 132 // If the response body is complete, we can just reuse the socket. |
134 stream_->Close(false /* reusable */); | 133 stream_->Close(false /* reusable */); |
135 } else if (stream_->IsSpdyHttpStream()) { | 134 } else if (stream_->IsSpdyHttpStream()) { |
136 // Doesn't really matter for SpdyHttpStream. Just close it. | 135 // Doesn't really matter for SpdyHttpStream. Just close it. |
137 stream_->Close(true /* not reusable */); | 136 stream_->Close(true /* not reusable */); |
138 } else { | 137 } else { |
139 // Otherwise, we try to drain the response body. | 138 // Otherwise, we try to drain the response body. |
140 // TODO(willchan): Consider moving this response body draining to the | 139 HttpStream* stream = stream_.release(); |
141 // stream implementation. For SPDY, there's clearly no point. For | 140 stream->Drain(session_); |
142 // HTTP, it can vary depending on whether or not we're pipelining. It's | |
143 // stream dependent, so the different subtypes should be implementing | |
144 // their solutions. | |
145 HttpResponseBodyDrainer* drainer = | |
146 new HttpResponseBodyDrainer(stream_.release()); | |
147 drainer->Start(session_); | |
148 // |drainer| will delete itself. | |
149 } | 141 } |
150 } | 142 } |
151 } | 143 } |
152 } | 144 } |
153 | 145 |
154 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info, | 146 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info, |
155 OldCompletionCallback* callback, | 147 OldCompletionCallback* callback, |
156 const BoundNetLog& net_log) { | 148 const BoundNetLog& net_log) { |
157 SIMPLE_STATS_COUNTER("HttpNetworkTransaction.Count"); | 149 SIMPLE_STATS_COUNTER("HttpNetworkTransaction.Count"); |
158 | 150 |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 | 1183 |
1192 switch (error) { | 1184 switch (error) { |
1193 // If we try to reuse a connection that the server is in the process of | 1185 // If we try to reuse a connection that the server is in the process of |
1194 // closing, we may end up successfully writing out our request (or a | 1186 // closing, we may end up successfully writing out our request (or a |
1195 // portion of our request) only to find a connection error when we try to | 1187 // portion of our request) only to find a connection error when we try to |
1196 // read from (or finish writing to) the socket. | 1188 // read from (or finish writing to) the socket. |
1197 case ERR_CONNECTION_RESET: | 1189 case ERR_CONNECTION_RESET: |
1198 case ERR_CONNECTION_CLOSED: | 1190 case ERR_CONNECTION_CLOSED: |
1199 case ERR_CONNECTION_ABORTED: | 1191 case ERR_CONNECTION_ABORTED: |
1200 if (ShouldResendRequest(error)) { | 1192 if (ShouldResendRequest(error)) { |
| 1193 net_log_.AddEvent( |
| 1194 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, |
| 1195 make_scoped_refptr(new NetLogIntegerParameter("net_error", error))); |
1201 ResetConnectionAndRequestForResend(); | 1196 ResetConnectionAndRequestForResend(); |
1202 error = OK; | 1197 error = OK; |
1203 } | 1198 } |
1204 break; | 1199 break; |
| 1200 case ERR_PIPELINE_EVICTION: |
1205 case ERR_SPDY_PING_FAILED: | 1201 case ERR_SPDY_PING_FAILED: |
1206 case ERR_SPDY_SERVER_REFUSED_STREAM: | 1202 case ERR_SPDY_SERVER_REFUSED_STREAM: |
| 1203 net_log_.AddEvent( |
| 1204 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, |
| 1205 make_scoped_refptr(new NetLogIntegerParameter("net_error", error))); |
1207 ResetConnectionAndRequestForResend(); | 1206 ResetConnectionAndRequestForResend(); |
1208 error = OK; | 1207 error = OK; |
1209 break; | 1208 break; |
1210 } | 1209 } |
1211 return error; | 1210 return error; |
1212 } | 1211 } |
1213 | 1212 |
1214 void HttpNetworkTransaction::ResetStateForRestart() { | 1213 void HttpNetworkTransaction::ResetStateForRestart() { |
1215 ResetStateForAuthRestart(); | 1214 ResetStateForAuthRestart(); |
1216 stream_.reset(); | 1215 stream_.reset(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, | 1342 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, |
1344 state); | 1343 state); |
1345 break; | 1344 break; |
1346 } | 1345 } |
1347 return description; | 1346 return description; |
1348 } | 1347 } |
1349 | 1348 |
1350 #undef STATE_CASE | 1349 #undef STATE_CASE |
1351 | 1350 |
1352 } // namespace net | 1351 } // namespace net |
OLD | NEW |