OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ | 5 #ifndef NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
6 #define NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ | 6 #define NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "crypto/ec_private_key.h" | |
davidben
2015/11/18 20:49:00
I think you can still forward-decl this.
nharper
2015/12/04 01:42:19
Yes I can. Done.
| |
17 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
18 #include "net/http/http_auth.h" | 19 #include "net/http/http_auth.h" |
19 #include "net/http/http_request_headers.h" | 20 #include "net/http/http_request_headers.h" |
20 #include "net/http/http_response_info.h" | 21 #include "net/http/http_response_info.h" |
21 #include "net/http/http_stream_factory.h" | 22 #include "net/http/http_stream_factory.h" |
22 #include "net/http/http_transaction.h" | 23 #include "net/http/http_transaction.h" |
23 #include "net/log/net_log.h" | 24 #include "net/log/net_log.h" |
24 #include "net/proxy/proxy_service.h" | 25 #include "net/proxy/proxy_service.h" |
25 #include "net/socket/connection_attempts.h" | 26 #include "net/socket/connection_attempts.h" |
27 #include "net/ssl/channel_id_service.h" | |
26 #include "net/ssl/ssl_config_service.h" | 28 #include "net/ssl/ssl_config_service.h" |
27 #include "net/ssl/ssl_failure_state.h" | 29 #include "net/ssl/ssl_failure_state.h" |
28 #include "net/websockets/websocket_handshake_stream_base.h" | 30 #include "net/websockets/websocket_handshake_stream_base.h" |
29 | 31 |
30 namespace net { | 32 namespace net { |
31 | 33 |
32 class ClientSocketHandle; | 34 class ClientSocketHandle; |
33 class HttpAuthController; | 35 class HttpAuthController; |
34 class HttpNetworkSession; | 36 class HttpNetworkSession; |
35 class HttpStream; | 37 class HttpStream; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 enum State { | 132 enum State { |
131 STATE_NOTIFY_BEFORE_CREATE_STREAM, | 133 STATE_NOTIFY_BEFORE_CREATE_STREAM, |
132 STATE_CREATE_STREAM, | 134 STATE_CREATE_STREAM, |
133 STATE_CREATE_STREAM_COMPLETE, | 135 STATE_CREATE_STREAM_COMPLETE, |
134 STATE_INIT_STREAM, | 136 STATE_INIT_STREAM, |
135 STATE_INIT_STREAM_COMPLETE, | 137 STATE_INIT_STREAM_COMPLETE, |
136 STATE_GENERATE_PROXY_AUTH_TOKEN, | 138 STATE_GENERATE_PROXY_AUTH_TOKEN, |
137 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, | 139 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, |
138 STATE_GENERATE_SERVER_AUTH_TOKEN, | 140 STATE_GENERATE_SERVER_AUTH_TOKEN, |
139 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, | 141 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, |
142 STATE_GET_TOKEN_BINDING_KEY, | |
143 STATE_GET_TOKEN_BINDING_KEY_COMPLETE, | |
140 STATE_INIT_REQUEST_BODY, | 144 STATE_INIT_REQUEST_BODY, |
141 STATE_INIT_REQUEST_BODY_COMPLETE, | 145 STATE_INIT_REQUEST_BODY_COMPLETE, |
142 STATE_BUILD_REQUEST, | 146 STATE_BUILD_REQUEST, |
143 STATE_BUILD_REQUEST_COMPLETE, | 147 STATE_BUILD_REQUEST_COMPLETE, |
144 STATE_SEND_REQUEST, | 148 STATE_SEND_REQUEST, |
145 STATE_SEND_REQUEST_COMPLETE, | 149 STATE_SEND_REQUEST_COMPLETE, |
146 STATE_READ_HEADERS, | 150 STATE_READ_HEADERS, |
147 STATE_READ_HEADERS_COMPLETE, | 151 STATE_READ_HEADERS_COMPLETE, |
148 STATE_READ_BODY, | 152 STATE_READ_BODY, |
149 STATE_READ_BODY_COMPLETE, | 153 STATE_READ_BODY_COMPLETE, |
150 STATE_DRAIN_BODY_FOR_AUTH_RESTART, | 154 STATE_DRAIN_BODY_FOR_AUTH_RESTART, |
151 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, | 155 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, |
152 STATE_NONE | 156 STATE_NONE |
153 }; | 157 }; |
154 | 158 |
155 bool IsSecureRequest() const; | 159 bool IsSecureRequest() const; |
160 bool IsTokenBindingEnabled() const; | |
161 void RecordTokenBindingSupport() const; | |
156 | 162 |
157 // Returns true if the request is using an HTTP(S) proxy without being | 163 // Returns true if the request is using an HTTP(S) proxy without being |
158 // tunneled via the CONNECT method. | 164 // tunneled via the CONNECT method. |
159 bool UsingHttpProxyWithoutTunnel() const; | 165 bool UsingHttpProxyWithoutTunnel() const; |
160 | 166 |
161 void DoCallback(int result); | 167 void DoCallback(int result); |
162 void OnIOComplete(int result); | 168 void OnIOComplete(int result); |
163 | 169 |
164 // Runs the state transition loop. | 170 // Runs the state transition loop. |
165 int DoLoop(int result); | 171 int DoLoop(int result); |
166 | 172 |
167 // Each of these methods corresponds to a State value. Those with an input | 173 // Each of these methods corresponds to a State value. Those with an input |
168 // argument receive the result from the previous state. If a method returns | 174 // argument receive the result from the previous state. If a method returns |
169 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the | 175 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the |
170 // next state method as the result arg. | 176 // next state method as the result arg. |
171 int DoNotifyBeforeCreateStream(); | 177 int DoNotifyBeforeCreateStream(); |
172 int DoCreateStream(); | 178 int DoCreateStream(); |
173 int DoCreateStreamComplete(int result); | 179 int DoCreateStreamComplete(int result); |
174 int DoInitStream(); | 180 int DoInitStream(); |
175 int DoInitStreamComplete(int result); | 181 int DoInitStreamComplete(int result); |
176 int DoGenerateProxyAuthToken(); | 182 int DoGenerateProxyAuthToken(); |
177 int DoGenerateProxyAuthTokenComplete(int result); | 183 int DoGenerateProxyAuthTokenComplete(int result); |
178 int DoGenerateServerAuthToken(); | 184 int DoGenerateServerAuthToken(); |
179 int DoGenerateServerAuthTokenComplete(int result); | 185 int DoGenerateServerAuthTokenComplete(int result); |
186 int DoGetTokenBindingKey(); | |
187 int DoGetTokenBindingKeyComplete(int result); | |
180 int DoInitRequestBody(); | 188 int DoInitRequestBody(); |
181 int DoInitRequestBodyComplete(int result); | 189 int DoInitRequestBodyComplete(int result); |
182 int DoBuildRequest(); | 190 int DoBuildRequest(); |
183 int DoBuildRequestComplete(int result); | 191 int DoBuildRequestComplete(int result); |
184 int DoSendRequest(); | 192 int DoSendRequest(); |
185 int DoSendRequestComplete(int result); | 193 int DoSendRequestComplete(int result); |
186 int DoReadHeaders(); | 194 int DoReadHeaders(); |
187 int DoReadHeadersComplete(int result); | 195 int DoReadHeadersComplete(int result); |
188 int DoReadBody(); | 196 int DoReadBody(); |
189 int DoReadBodyComplete(int result); | 197 int DoReadBodyComplete(int result); |
190 int DoDrainBodyForAuthRestart(); | 198 int DoDrainBodyForAuthRestart(); |
191 int DoDrainBodyForAuthRestartComplete(int result); | 199 int DoDrainBodyForAuthRestartComplete(int result); |
192 | 200 |
193 void BuildRequestHeaders(bool using_http_proxy_without_tunnel); | 201 void BuildRequestHeaders(bool using_http_proxy_without_tunnel); |
202 std::string BuildTokenBindingHeader(); | |
194 | 203 |
195 // Writes a log message to help debugging in the field when we block a proxy | 204 // Writes a log message to help debugging in the field when we block a proxy |
196 // response to a CONNECT request. | 205 // response to a CONNECT request. |
197 void LogBlockedTunnelResponse(int response_code) const; | 206 void LogBlockedTunnelResponse(int response_code) const; |
198 | 207 |
199 // Called to handle a client certificate request. | 208 // Called to handle a client certificate request. |
200 int HandleCertificateRequest(int error); | 209 int HandleCertificateRequest(int error); |
201 | 210 |
202 // Called wherever ERR_HTTP_1_1_REQUIRED or | 211 // Called wherever ERR_HTTP_1_1_REQUIRED or |
203 // ERR_PROXY_HTTP_1_1_REQUIRED has to be handled. | 212 // ERR_PROXY_HTTP_1_1_REQUIRED has to be handled. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 SSLFailureState server_ssl_failure_state_; | 314 SSLFailureState server_ssl_failure_state_; |
306 // fallback_error_code contains the error code that caused the last TLS | 315 // fallback_error_code contains the error code that caused the last TLS |
307 // fallback. If the fallback connection results in | 316 // fallback. If the fallback connection results in |
308 // ERR_SSL_INAPPROPRIATE_FALLBACK (i.e. the server indicated that the | 317 // ERR_SSL_INAPPROPRIATE_FALLBACK (i.e. the server indicated that the |
309 // fallback should not have been needed) then we use this value to return the | 318 // fallback should not have been needed) then we use this value to return the |
310 // original error that triggered the fallback. | 319 // original error that triggered the fallback. |
311 int fallback_error_code_; | 320 int fallback_error_code_; |
312 // The SSLFailureState which caused the last TLS version fallback. | 321 // The SSLFailureState which caused the last TLS version fallback. |
313 SSLFailureState fallback_failure_state_; | 322 SSLFailureState fallback_failure_state_; |
314 | 323 |
324 // Key to use for signing message in Token Binding header. | |
325 scoped_ptr<crypto::ECPrivateKey> token_binding_key_; | |
326 // Object to manage lookup of |token_binding_key_|. | |
327 ChannelIDService::Request token_binding_request_; | |
328 | |
315 HttpRequestHeaders request_headers_; | 329 HttpRequestHeaders request_headers_; |
316 | 330 |
317 // The size in bytes of the buffer we use to drain the response body that | 331 // The size in bytes of the buffer we use to drain the response body that |
318 // we want to throw away. The response body is typically a small error | 332 // we want to throw away. The response body is typically a small error |
319 // page just a few hundred bytes long. | 333 // page just a few hundred bytes long. |
320 static const int kDrainBodyBufferSize = 1024; | 334 static const int kDrainBodyBufferSize = 1024; |
321 | 335 |
322 // User buffer and length passed to the Read method. | 336 // User buffer and length passed to the Read method. |
323 scoped_refptr<IOBuffer> read_buf_; | 337 scoped_refptr<IOBuffer> read_buf_; |
324 int read_buf_len_; | 338 int read_buf_len_; |
(...skipping 28 matching lines...) Expand all Loading... | |
353 | 367 |
354 ConnectionAttempts connection_attempts_; | 368 ConnectionAttempts connection_attempts_; |
355 IPEndPoint remote_endpoint_; | 369 IPEndPoint remote_endpoint_; |
356 | 370 |
357 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); | 371 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); |
358 }; | 372 }; |
359 | 373 |
360 } // namespace net | 374 } // namespace net |
361 | 375 |
362 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ | 376 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
OLD | NEW |