blob: c35c0651057bcf6e21f61bdc2c20fdd55a7dd2e5 [file] [log] [blame]
[email protected]448d4ca52012-03-04 04:12:231// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit586acc5fe2008-07-26 22:42:524
5#ifndef NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
6#define NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
7
sclittlefb249892015-09-10 21:33:228#include <stdint.h>
9
danakj1fd259a02016-04-16 03:17:0910#include <memory>
[email protected]96d570e42008-08-05 22:43:0411#include <string>
12
[email protected]8822f382010-07-30 21:49:0313#include "base/gtest_prod_util.h"
Avi Drissman13fc8932015-12-20 04:40:4614#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1515#include "base/memory/ref_counted.h"
[email protected]66e96c42013-06-28 15:20:3116#include "base/time/time.h"
Douglas Creager3cb042052018-11-06 23:08:5217#include "build/buildflag.h"
nharperb7441ef2016-01-25 23:54:1418#include "crypto/ec_private_key.h"
Bence Béky046f8c82018-06-12 02:26:0419#include "net/base/completion_once_callback.h"
Bence Béky61f756c2018-04-25 14:17:5320#include "net/base/completion_repeating_callback.h"
zhongyi48704c182015-12-07 07:52:0221#include "net/base/net_error_details.h"
bnc81c46c1f2016-10-04 16:25:5922#include "net/base/net_export.h"
Matt Menkeb32ba5122019-09-10 19:17:0523#include "net/base/network_isolation_key.h"
[email protected]8e6441ca2010-08-19 05:56:3824#include "net/base/request_priority.h"
[email protected]c3b35c22008-09-27 03:19:4225#include "net/http/http_auth.h"
[email protected]b94f92d2010-10-27 16:45:2026#include "net/http/http_request_headers.h"
initial.commit586acc5fe2008-07-26 22:42:5227#include "net/http/http_response_info.h"
[email protected]102e27c2011-02-23 01:01:3128#include "net/http/http_stream_factory.h"
Bence Béky6b44abf2018-04-11 10:32:5129#include "net/http/http_stream_request.h"
initial.commit586acc5fe2008-07-26 22:42:5230#include "net/http/http_transaction.h"
mikecironef22f9812016-10-04 03:40:1931#include "net/log/net_log_with_source.h"
Douglas Creager3cb042052018-11-06 23:08:5232#include "net/net_buildflags.h"
Lily Houghtonffe89daa02018-03-09 18:30:0333#include "net/proxy_resolution/proxy_resolution_service.h"
ttuttle1f2d7e92015-04-28 16:17:4734#include "net/socket/connection_attempts.h"
[email protected]536fd0b2013-03-14 17:41:5735#include "net/ssl/ssl_config_service.h"
[email protected]831e4a32013-11-14 02:14:4436#include "net/websockets/websocket_handshake_stream_base.h"
initial.commit586acc5fe2008-07-26 22:42:5237
initial.commit586acc5fe2008-07-26 22:42:5238namespace net {
39
xunjieli5749218c2016-03-22 16:43:0640class BidirectionalStreamImpl;
[email protected]8e6441ca2010-08-19 05:56:3841class HttpAuthController;
initial.commit586acc5fe2008-07-26 22:42:5242class HttpNetworkSession;
yhiranoa7e05bb2014-11-06 05:40:3943class HttpStream;
[email protected]8e6441ca2010-08-19 05:56:3844class IOBuffer;
[email protected]597a1ab2014-06-26 08:12:2745class ProxyInfo;
svaldez7872fd02015-11-19 21:10:5446class SSLPrivateKey;
[email protected]82918cc2010-08-25 17:24:5047struct HttpRequestInfo;
initial.commit586acc5fe2008-07-26 22:42:5248
[email protected]172da1b2011-08-12 15:52:2649class NET_EXPORT_PRIVATE HttpNetworkTransaction
50 : public HttpTransaction,
Helen Lib495c3802018-03-30 13:46:0951 public HttpStreamRequest::Delegate {
initial.commit586acc5fe2008-07-26 22:42:5252 public:
[email protected]262eec82013-03-19 21:01:3653 HttpNetworkTransaction(RequestPriority priority,
54 HttpNetworkSession* session);
initial.commit586acc5fe2008-07-26 22:42:5255
dchengb03027d2014-10-21 12:00:2056 ~HttpNetworkTransaction() override;
[email protected]af4876d2008-10-21 23:10:5757
initial.commit586acc5fe2008-07-26 22:42:5258 // HttpTransaction methods:
dchengb03027d2014-10-21 12:00:2059 int Start(const HttpRequestInfo* request_info,
Bence Béky046f8c82018-06-12 02:26:0460 CompletionOnceCallback callback,
tfarina42834112016-09-22 13:38:2061 const NetLogWithSource& net_log) override;
Bence Béky046f8c82018-06-12 02:26:0462 int RestartIgnoringLastError(CompletionOnceCallback callback) override;
mattm436ccfe2017-06-19 20:24:0863 int RestartWithCertificate(scoped_refptr<X509Certificate> client_cert,
64 scoped_refptr<SSLPrivateKey> client_private_key,
Bence Béky046f8c82018-06-12 02:26:0465 CompletionOnceCallback callback) override;
dchengb03027d2014-10-21 12:00:2066 int RestartWithAuth(const AuthCredentials& credentials,
Bence Béky046f8c82018-06-12 02:26:0467 CompletionOnceCallback callback) override;
dchengb03027d2014-10-21 12:00:2068 bool IsReadyToRestartForAuth() override;
[email protected]0757e7702009-03-27 04:00:2269
dchengb03027d2014-10-21 12:00:2070 int Read(IOBuffer* buf,
71 int buf_len,
Bence Béky046f8c82018-06-12 02:26:0472 CompletionOnceCallback callback) override;
dchengb03027d2014-10-21 12:00:2073 void StopCaching() override;
sclittle4de1bab92015-09-22 21:28:2474 int64_t GetTotalReceivedBytes() const override;
sclittlefb249892015-09-10 21:33:2275 int64_t GetTotalSentBytes() const override;
dchengb03027d2014-10-21 12:00:2076 void DoneReading() override;
77 const HttpResponseInfo* GetResponseInfo() const override;
78 LoadState GetLoadState() const override;
dchengb03027d2014-10-21 12:00:2079 void SetQuicServerInfo(QuicServerInfo* quic_server_info) override;
80 bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override;
ttuttled9dbc652015-09-29 20:00:5981 bool GetRemoteEndpoint(IPEndPoint* endpoint) const override;
zhongyi48704c182015-12-07 07:52:0282 void PopulateNetErrorDetails(NetErrorDetails* details) const override;
dchengb03027d2014-10-21 12:00:2083 void SetPriority(RequestPriority priority) override;
84 void SetWebSocketHandshakeStreamCreateHelper(
mostynbba063d6032014-10-09 11:01:1385 WebSocketHandshakeStreamBase::CreateHelper* create_helper) override;
dchengb03027d2014-10-21 12:00:2086 void SetBeforeNetworkStartCallback(
mostynbba063d6032014-10-09 11:01:1387 const BeforeNetworkStartCallback& callback) override;
ryansturm49a8cb12016-06-15 16:51:0988 void SetBeforeHeadersSentCallback(
89 const BeforeHeadersSentCallback& callback) override;
Andrey Kosyakov2e893e62017-08-31 17:00:5290 void SetRequestHeadersCallback(RequestHeadersCallback callback) override;
91 void SetResponseHeadersCallback(ResponseHeadersCallback callback) override;
Andrey Kosyakov83a6eee2017-08-14 19:20:0492
dchengb03027d2014-10-21 12:00:2093 int ResumeNetworkStart() override;
initial.commit586acc5fe2008-07-26 22:42:5294
[email protected]102e27c2011-02-23 01:01:3195 // HttpStreamRequest::Delegate methods:
dchengb03027d2014-10-21 12:00:2096 void OnStreamReady(const SSLConfig& used_ssl_config,
97 const ProxyInfo& used_proxy_info,
bnc5029f4632017-06-08 16:19:0098 std::unique_ptr<HttpStream> stream) override;
99 void OnBidirectionalStreamImplReady(
100 const SSLConfig& used_ssl_config,
101 const ProxyInfo& used_proxy_info,
102 std::unique_ptr<BidirectionalStreamImpl> stream) override;
dchengb03027d2014-10-21 12:00:20103 void OnWebSocketHandshakeStreamReady(
[email protected]3732cea2013-06-21 06:50:50104 const SSLConfig& used_ssl_config,
105 const ProxyInfo& used_proxy_info,
bnc5029f4632017-06-08 16:19:00106 std::unique_ptr<WebSocketHandshakeStreamBase> stream) override;
Ryan Hamilton75f197262017-08-17 14:00:07107 void OnStreamFailed(int status,
108 const NetErrorDetails& net_error_details,
Wojciech Dzierżanowskiabdeeaf2019-04-01 20:16:22109 const SSLConfig& used_ssl_config,
dalyk6d7a8c52019-12-18 21:43:01110 const ProxyInfo& used_proxy_info,
111 ResolveErrorInfo resolve_error_info) override;
dchengb03027d2014-10-21 12:00:20112 void OnCertificateError(int status,
113 const SSLConfig& used_ssl_config,
114 const SSLInfo& ssl_info) override;
115 void OnNeedsProxyAuth(const HttpResponseInfo& response_info,
116 const SSLConfig& used_ssl_config,
117 const ProxyInfo& used_proxy_info,
118 HttpAuthController* auth_controller) override;
119 void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
120 SSLCertRequestInfo* cert_info) override;
[email protected]8e6441ca2010-08-19 05:56:38121
zhongyi48704c182015-12-07 07:52:02122 void OnQuicBroken() override;
ttuttle1f2d7e92015-04-28 16:17:47123 void GetConnectionAttempts(ConnectionAttempts* out) const override;
124
initial.commit586acc5fe2008-07-26 22:42:52125 private:
bnc1f61cdf2016-11-28 18:03:45126 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, ResetStateForRestart);
Bence Béky2fcf4fa2018-04-06 20:06:01127 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest,
128 CreateWebSocketHandshakeStream);
bnc1f61cdf2016-11-28 18:03:45129 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, WindowUpdateReceived);
130 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, WindowUpdateSent);
131 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, WindowUpdateOverflow);
132 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, FlowControlStallResume);
[email protected]513963e2013-06-15 01:53:04133 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest,
[email protected]ca6459f862012-04-11 19:43:20134 FlowControlStallResumeAfterSettings);
[email protected]513963e2013-06-15 01:53:04135 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest,
[email protected]ca6459f862012-04-11 19:43:20136 FlowControlNegativeSendWindowSize);
[email protected]89ceba9a2009-03-21 03:46:06137
[email protected]d207a5f2009-06-04 05:28:40138 enum State {
[email protected]1826a402014-01-08 15:40:48139 STATE_NOTIFY_BEFORE_CREATE_STREAM,
[email protected]82918cc2010-08-25 17:24:50140 STATE_CREATE_STREAM,
141 STATE_CREATE_STREAM_COMPLETE,
[email protected]351ab642010-08-05 16:55:31142 STATE_INIT_STREAM,
143 STATE_INIT_STREAM_COMPLETE,
[email protected]044de0642010-06-17 10:42:15144 STATE_GENERATE_PROXY_AUTH_TOKEN,
145 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE,
146 STATE_GENERATE_SERVER_AUTH_TOKEN,
147 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE,
[email protected]daddea62012-09-19 05:51:13148 STATE_INIT_REQUEST_BODY,
149 STATE_INIT_REQUEST_BODY_COMPLETE,
[email protected]4875ba12011-03-30 22:31:51150 STATE_BUILD_REQUEST,
151 STATE_BUILD_REQUEST_COMPLETE,
[email protected]0877e3d2009-10-17 22:29:57152 STATE_SEND_REQUEST,
153 STATE_SEND_REQUEST_COMPLETE,
[email protected]d207a5f2009-06-04 05:28:40154 STATE_READ_HEADERS,
155 STATE_READ_HEADERS_COMPLETE,
156 STATE_READ_BODY,
157 STATE_READ_BODY_COMPLETE,
158 STATE_DRAIN_BODY_FOR_AUTH_RESTART,
159 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE,
160 STATE_NONE
161 };
162
Adam Ricecb76ac62015-02-20 05:33:25163 bool IsSecureRequest() const;
[email protected]564b4912010-03-09 16:30:42164
Adam Rice425cf122015-01-19 06:18:24165 // Returns true if the request is using an HTTP(S) proxy without being
166 // tunneled via the CONNECT method.
167 bool UsingHttpProxyWithoutTunnel() const;
168
initial.commit586acc5fe2008-07-26 22:42:52169 void DoCallback(int result);
170 void OnIOComplete(int result);
171
172 // Runs the state transition loop.
173 int DoLoop(int result);
174
175 // Each of these methods corresponds to a State value. Those with an input
176 // argument receive the result from the previous state. If a method returns
177 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the
178 // next state method as the result arg.
[email protected]1826a402014-01-08 15:40:48179 int DoNotifyBeforeCreateStream();
[email protected]82918cc2010-08-25 17:24:50180 int DoCreateStream();
181 int DoCreateStreamComplete(int result);
[email protected]351ab642010-08-05 16:55:31182 int DoInitStream();
183 int DoInitStreamComplete(int result);
[email protected]044de0642010-06-17 10:42:15184 int DoGenerateProxyAuthToken();
185 int DoGenerateProxyAuthTokenComplete(int result);
186 int DoGenerateServerAuthToken();
187 int DoGenerateServerAuthTokenComplete(int result);
[email protected]daddea62012-09-19 05:51:13188 int DoInitRequestBody();
189 int DoInitRequestBodyComplete(int result);
[email protected]4875ba12011-03-30 22:31:51190 int DoBuildRequest();
191 int DoBuildRequestComplete(int result);
[email protected]0877e3d2009-10-17 22:29:57192 int DoSendRequest();
193 int DoSendRequestComplete(int result);
initial.commit586acc5fe2008-07-26 22:42:52194 int DoReadHeaders();
195 int DoReadHeadersComplete(int result);
196 int DoReadBody();
197 int DoReadBodyComplete(int result);
[email protected]2d2697f92009-02-18 21:00:32198 int DoDrainBodyForAuthRestart();
199 int DoDrainBodyForAuthRestartComplete(int result);
initial.commit586acc5fe2008-07-26 22:42:52200
nharperb7441ef2016-01-25 23:54:14201 int BuildRequestHeaders(bool using_http_proxy_without_tunnel);
[email protected]2979a492011-04-06 00:29:14202
Douglas Creager3cb042052018-11-06 23:08:52203#if BUILDFLAG(ENABLE_REPORTING)
Douglas Creager134b52e2018-11-09 18:00:14204 // Processes the Report-To header, if one exists. This header configures where
205 // the Reporting API (in //net/reporting) will send reports for the origin.
206 void ProcessReportToHeader();
207
Douglas Creager3cb042052018-11-06 23:08:52208 // Processes the NEL header, if one exists. This header configures whether
209 // network errors will be reported to a specified group of endpoints using the
210 // Reporting API.
211 void ProcessNetworkErrorLoggingHeader();
Douglas Creageref5eecdc2018-11-09 20:50:36212
Lily Chenfec60d92019-01-24 01:16:42213 // Calls GenerateNetworkErrorLoggingReport() if |rv| represents a NET_ERROR
214 // other than ERR_IO_PENDING.
215 void GenerateNetworkErrorLoggingReportIfError(int rv);
216
Douglas Creageref5eecdc2018-11-09 20:50:36217 // Generates a NEL report about this request. The NetworkErrorLoggingService
218 // will discard the report if there is no NEL policy registered for this
219 // origin.
220 void GenerateNetworkErrorLoggingReport(int rv);
Douglas Creager3cb042052018-11-06 23:08:52221#endif
222
[email protected]9f9f86c2009-03-12 22:32:42223 // Writes a log message to help debugging in the field when we block a proxy
224 // response to a CONNECT request.
[email protected]af89ba62009-03-16 20:26:38225 void LogBlockedTunnelResponse(int response_code) const;
[email protected]9f9f86c2009-03-12 22:32:42226
bncfacdd852015-01-09 19:22:54227 // Called wherever ERR_HTTP_1_1_REQUIRED or
228 // ERR_PROXY_HTTP_1_1_REQUIRED has to be handled.
229 int HandleHttp11Required(int error);
230
David Benjamin76a40ad2018-02-24 22:22:08231 // Called to possibly handle a client authentication error. Sets next_state_
[email protected]bd0b6772011-01-11 19:59:30232 // and returns OK if recovering from the error. Otherwise, the same error
233 // code is returned.
David Benjamin76a40ad2018-02-24 22:22:08234 int HandleSSLClientAuthError(int error);
[email protected]bd0b6772011-01-11 19:59:30235
initial.commit586acc5fe2008-07-26 22:42:52236 // Called to possibly recover from the given error. Sets next_state_ and
237 // returns OK if recovering from the error. Otherwise, the same error code
238 // is returned.
239 int HandleIOError(int error);
240
[email protected]0877e3d2009-10-17 22:29:57241 // Gets the response headers from the HttpStream.
242 HttpResponseHeaders* GetResponseHeaders() const;
243
[email protected]a34f61ee2014-03-18 20:59:49244 // Called when the socket is unexpectedly closed. Returns true if the request
245 // should be resent in case of a socket reuse/close race.
246 bool ShouldResendRequest() const;
[email protected]1c773ea12009-04-28 19:58:42247
Biljith Jayan45a41722017-08-16 18:43:14248 // Returns true if there have already been |kMaxRetryAttempts| retries for
249 // HTTP2 or QUIC network errors, and no further retries should be attempted.
250 bool HasExceededMaxRetries() const;
251
David Benjamin83ddfb32018-03-30 01:07:52252 // Increments the number of restarts and returns true if the restart may
253 // proceed.
254 bool CheckMaxRestarts();
255
[email protected]1c773ea12009-04-28 19:58:42256 // Resets the connection and the request headers for resend. Called when
257 // ShouldResendRequest() is true.
258 void ResetConnectionAndRequestForResend();
[email protected]2a5c76b2008-09-25 22:15:16259
[email protected]f9ee6b52008-11-08 06:46:23260 // Sets up the state machine to restart the transaction with auth.
261 void PrepareForAuthRestart(HttpAuth::Target target);
262
[email protected]2d2697f92009-02-18 21:00:32263 // Called when we don't need to drain the response body or have drained it.
264 // Resets |connection_| unless |keep_alive| is true, then calls
265 // ResetStateForRestart. Sets |next_state_| appropriately.
266 void DidDrainBodyForAuthRestart(bool keep_alive);
267
[email protected]f9ee6b52008-11-08 06:46:23268 // Resets the members of the transaction so it can be restarted.
[email protected]c3b35c22008-09-27 03:19:42269 void ResetStateForRestart();
270
[email protected]697ef4c2010-10-14 16:38:58271 // Resets the members of the transaction, except |stream_|, which needs
272 // to be maintained for multi-round auth.
273 void ResetStateForAuthRestart();
274
zhongyica364fbb2015-12-12 03:39:12275 // Caches network error details from the stream if available
276 // and resets the stream.
277 void CacheNetErrorDetailsAndResetStream();
278
[email protected]1c773ea12009-04-28 19:58:42279 // Returns true if we should try to add a Proxy-Authorization header
280 bool ShouldApplyProxyAuth() const;
[email protected]c3b35c22008-09-27 03:19:42281
[email protected]1c773ea12009-04-28 19:58:42282 // Returns true if we should try to add an Authorization header.
283 bool ShouldApplyServerAuth() const;
284
[email protected]f9ee6b52008-11-08 06:46:23285 // Handles HTTP status code 401 or 407.
[email protected]0757e7702009-03-27 04:00:22286 // HandleAuthChallenge() returns a network error code, or OK on success.
287 // May update |pending_auth_target_| or |response_.auth_challenge|.
[email protected]e772db3f2010-07-12 18:11:13288 int HandleAuthChallenge();
[email protected]f9ee6b52008-11-08 06:46:23289
[email protected]8e6441ca2010-08-19 05:56:38290 // Returns true if we have auth credentials for the given target.
291 bool HaveAuth(HttpAuth::Target target) const;
[email protected]c3b35c22008-09-27 03:19:42292
[email protected]228404f2010-06-24 04:31:41293 // Get the {scheme, host, path, port} for the authentication target
294 GURL AuthURL(HttpAuth::Target target) const;
[email protected]044de0642010-06-17 10:42:15295
[email protected]831e4a32013-11-14 02:14:44296 // Returns true if this transaction is for a WebSocket handshake
297 bool ForWebSocketHandshake() const;
298
ttuttle1f2d7e92015-04-28 16:17:47299 void CopyConnectionAttemptsFromStreamRequest();
300
eustasc7d27da2017-04-06 10:33:20301 // Returns true if response "Content-Encoding" headers respect
302 // "Accept-Encoding".
303 bool ContentEncodingsValid() const;
304
[email protected]e772db3f2010-07-12 18:11:13305 scoped_refptr<HttpAuthController>
306 auth_controllers_[HttpAuth::AUTH_NUM_TARGETS];
[email protected]c3b35c22008-09-27 03:19:42307
[email protected]0757e7702009-03-27 04:00:22308 // Whether this transaction is waiting for proxy auth, server auth, or is
309 // not waiting for any auth at all. |pending_auth_target_| is read and
310 // cleared by RestartWithAuth().
311 HttpAuth::Target pending_auth_target_;
312
Bence Béky61f756c2018-04-25 14:17:53313 CompletionRepeatingCallback io_callback_;
Bence Béky046f8c82018-06-12 02:26:04314 CompletionOnceCallback callback_;
initial.commit586acc5fe2008-07-26 22:42:52315
[email protected]3fe8d2f82013-10-17 08:56:07316 HttpNetworkSession* session_;
initial.commit586acc5fe2008-07-26 22:42:52317
tfarina42834112016-09-22 13:38:20318 NetLogWithSource net_log_;
shivanisha0b440852016-10-18 15:48:15319
320 // Reset to null at the start of the Read state machine.
initial.commit586acc5fe2008-07-26 22:42:52321 const HttpRequestInfo* request_;
shivanisha0b440852016-10-18 15:48:15322
323 // The requested URL.
324 GURL url_;
[email protected]262eec82013-03-19 21:01:36325 RequestPriority priority_;
[email protected]a7e41312009-12-16 23:18:14326 HttpResponseInfo response_;
initial.commit586acc5fe2008-07-26 22:42:52327
Matt Menkeb32ba5122019-09-10 19:17:05328 // Copied from |request_|, as it's needed after the response body has been
329 // read.
330 NetworkIsolationKey network_isolation_key_;
331
[email protected]102e27c2011-02-23 01:01:31332 // |proxy_info_| is the ProxyInfo used by the HttpStreamRequest.
[email protected]928fb582008-08-11 15:40:23333 ProxyInfo proxy_info_;
initial.commit586acc5fe2008-07-26 22:42:52334
danakj1fd259a02016-04-16 03:17:09335 std::unique_ptr<HttpStreamRequest> stream_request_;
336 std::unique_ptr<HttpStream> stream_;
[email protected]8e6441ca2010-08-19 05:56:38337
[email protected]0877e3d2009-10-17 22:29:57338 // True if we've validated the headers that the stream parser has returned.
339 bool headers_valid_;
340
Steven Valdezb4ff0412018-01-18 22:39:27341 // True if we can send the request over early data.
342 bool can_send_early_data_;
343
David Benjaminbac8dff2019-08-07 01:30:41344 // True if the client certificate for the server (rather than the proxy) was
345 // configured in this transaction.
346 bool configured_client_cert_for_server_;
David Benjamin76a40ad2018-02-24 22:22:08347
David Benjamin5cb91132018-04-06 05:54:49348 // SSL configuration used for the server and proxy, respectively. Note
349 // |server_ssl_config_| may be updated from the HttpStreamFactory, which will
350 // be applied on retry.
351 //
352 // TODO(davidben): Mutating it is weird and relies on HttpStreamFactory
353 // modifications being idempotent. Address this as part of other work to make
354 // sense of SSLConfig (related to https://crbug.com/488043).
[email protected]102957f2011-09-02 17:10:14355 SSLConfig server_ssl_config_;
356 SSLConfig proxy_ssl_config_;
[email protected]c5949a32008-10-08 17:28:23357
[email protected]b94f92d2010-10-27 16:45:20358 HttpRequestHeaders request_headers_;
Douglas Creageref5eecdc2018-11-09 20:50:36359#if BUILDFLAG(ENABLE_REPORTING)
Lily Chenfec60d92019-01-24 01:16:42360 // Whether a NEL report has already been generated. Reset when restarting.
361 bool network_error_logging_report_generated_;
Douglas Creageref5eecdc2018-11-09 20:50:36362 // Cache some fields from |request_| that we'll need to construct a NEL
363 // report about the request. (NEL report construction happens after we've
364 // cleared the |request_| pointer.)
365 std::string request_method_;
366 std::string request_referrer_;
367 std::string request_user_agent_;
368 int request_reporting_upload_depth_;
Lily Chenfec60d92019-01-24 01:16:42369 base::TimeTicks start_timeticks_;
Douglas Creageref5eecdc2018-11-09 20:50:36370#endif
[email protected]4ddaf2502008-10-23 18:26:19371
[email protected]2d2697f92009-02-18 21:00:32372 // The size in bytes of the buffer we use to drain the response body that
373 // we want to throw away. The response body is typically a small error
374 // page just a few hundred bytes long.
[email protected]81854c42010-09-22 03:39:36375 static const int kDrainBodyBufferSize = 1024;
[email protected]2d2697f92009-02-18 21:00:32376
initial.commit586acc5fe2008-07-26 22:42:52377 // User buffer and length passed to the Read method.
[email protected]9dea9e1f2009-01-29 00:30:47378 scoped_refptr<IOBuffer> read_buf_;
initial.commit586acc5fe2008-07-26 22:42:52379 int read_buf_len_;
380
sclittlefb249892015-09-10 21:33:22381 // Total number of bytes received on all destroyed HttpStreams for this
382 // transaction.
sclittle4de1bab92015-09-22 21:28:24383 int64_t total_received_bytes_;
[email protected]b8015c42013-12-24 15:18:19384
sclittlefb249892015-09-10 21:33:22385 // Total number of bytes sent on all destroyed HttpStreams for this
386 // transaction.
387 int64_t total_sent_bytes_;
388
[email protected]58e32bb2013-01-21 18:23:25389 // When the transaction started / finished sending the request, including
390 // the body, if present.
391 base::TimeTicks send_start_time_;
392 base::TimeTicks send_end_time_;
393
[email protected]d207a5f2009-06-04 05:28:40394 // The next state in the state machine.
initial.commit586acc5fe2008-07-26 22:42:52395 State next_state_;
[email protected]2ff8b312010-04-26 22:20:54396
[email protected]a7ea8832010-07-12 17:54:54397 // True when the tunnel is in the process of being established - we can't
398 // read from the socket until the tunnel is done.
399 bool establishing_tunnel_;
400
bnc8016c1f2017-03-31 02:11:29401 // Enable pooling to a SpdySession with matching IP and certificate
402 // even if the SpdySessionKey is different.
403 bool enable_ip_based_pooling_;
404
bncaccd4962017-04-06 21:00:26405 // Enable using alternative services for the request.
406 bool enable_alternative_services_;
407
rch2f2991c2017-04-13 19:28:17408 // When a request is retried because of errors with the alternative service,
409 // this will store the alternative service used.
410 AlternativeService retried_alternative_service_;
411
[email protected]831e4a32013-11-14 02:14:44412 // The helper object to use to create WebSocketHandshakeStreamBase
413 // objects. Only relevant when establishing a WebSocket connection.
414 WebSocketHandshakeStreamBase::CreateHelper*
415 websocket_handshake_stream_base_create_helper_;
416
[email protected]1826a402014-01-08 15:40:48417 BeforeNetworkStartCallback before_network_start_callback_;
ryansturm49a8cb12016-06-15 16:51:09418 BeforeHeadersSentCallback before_headers_sent_callback_;
Andrey Kosyakov83a6eee2017-08-14 19:20:04419 RequestHeadersCallback request_headers_callback_;
Andrey Kosyakov2e893e62017-08-31 17:00:52420 ResponseHeadersCallback response_headers_callback_;
[email protected]1826a402014-01-08 15:40:48421
ttuttle1f2d7e92015-04-28 16:17:47422 ConnectionAttempts connection_attempts_;
ttuttled9dbc652015-09-29 20:00:59423 IPEndPoint remote_endpoint_;
zhongyica364fbb2015-12-12 03:39:12424 // Network error details for this transaction.
425 NetErrorDetails net_error_details_;
rdsmith1d343be52016-10-21 20:37:50426
Bence Békyd0d69502019-06-25 19:47:18427 // Number of retries made for network errors like ERR_HTTP2_PING_FAILED,
428 // ERR_HTTP2_SERVER_REFUSED_STREAM, ERR_QUIC_HANDSHAKE_FAILED and
Biljith Jayan45a41722017-08-16 18:43:14429 // ERR_QUIC_PROTOCOL_ERROR. Currently we stop after 3 tries
430 // (including the initial request) and fail the request.
431 // This count excludes retries on reused sockets since a well
432 // behaved server may time those out and thus the number
433 // of times we can retry a request on reused sockets is limited.
434 size_t retry_attempts_;
435
David Benjamin83ddfb32018-03-30 01:07:52436 // Number of times the transaction was restarted via a RestartWith* call.
437 size_t num_restarts_;
438
[email protected]2ff8b312010-04-26 22:20:54439 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction);
initial.commit586acc5fe2008-07-26 22:42:52440};
441
442} // namespace net
443
444#endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_