OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 int DoSSLConnectOverTunnel(); | 68 int DoSSLConnectOverTunnel(); |
69 int DoSSLConnectOverTunnelComplete(int result); | 69 int DoSSLConnectOverTunnelComplete(int result); |
70 int DoWriteHeaders(); | 70 int DoWriteHeaders(); |
71 int DoWriteHeadersComplete(int result); | 71 int DoWriteHeadersComplete(int result); |
72 int DoWriteBody(); | 72 int DoWriteBody(); |
73 int DoWriteBodyComplete(int result); | 73 int DoWriteBodyComplete(int result); |
74 int DoReadHeaders(); | 74 int DoReadHeaders(); |
75 int DoReadHeadersComplete(int result); | 75 int DoReadHeadersComplete(int result); |
76 int DoReadBody(); | 76 int DoReadBody(); |
77 int DoReadBodyComplete(int result); | 77 int DoReadBodyComplete(int result); |
| 78 int DoDrainBodyForAuthRestart(); |
| 79 int DoDrainBodyForAuthRestartComplete(int result); |
78 | 80 |
79 // Record histogram of latency (first byte sent till last byte received) as | 81 // Record histogram of latency (first byte sent till last byte received) as |
80 // well as effective bandwidth used. | 82 // well as effective bandwidth used. |
81 void LogTransactionMetrics() const; | 83 void LogTransactionMetrics() const; |
82 | 84 |
83 // Called when header_buf_ contains the complete response headers. | 85 // Called when header_buf_ contains the complete response headers. |
84 int DidReadResponseHeaders(); | 86 int DidReadResponseHeaders(); |
85 | 87 |
86 // Called to handle a certificate error. Returns OK if the error should be | 88 // Called to handle a certificate error. Returns OK if the error should be |
87 // ignored. Otherwise, stores the certificate in response_.ssl_info and | 89 // ignored. Otherwise, stores the certificate in response_.ssl_info and |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // Return true if based on the bytes read so far, the start of the | 121 // Return true if based on the bytes read so far, the start of the |
120 // status line is known. This is used to distingish between HTTP/0.9 | 122 // status line is known. This is used to distingish between HTTP/0.9 |
121 // responses (which have no status line) and HTTP/1.x responses. | 123 // responses (which have no status line) and HTTP/1.x responses. |
122 bool has_found_status_line_start() const { | 124 bool has_found_status_line_start() const { |
123 return header_buf_http_offset_ != -1; | 125 return header_buf_http_offset_ != -1; |
124 } | 126 } |
125 | 127 |
126 // Sets up the state machine to restart the transaction with auth. | 128 // Sets up the state machine to restart the transaction with auth. |
127 void PrepareForAuthRestart(HttpAuth::Target target); | 129 void PrepareForAuthRestart(HttpAuth::Target target); |
128 | 130 |
| 131 // Called when we don't need to drain the response body or have drained it. |
| 132 // Resets |connection_| unless |keep_alive| is true, then calls |
| 133 // ResetStateForRestart. Sets |next_state_| appropriately. |
| 134 void DidDrainBodyForAuthRestart(bool keep_alive); |
| 135 |
129 // Resets the members of the transaction so it can be restarted. | 136 // Resets the members of the transaction so it can be restarted. |
130 void ResetStateForRestart(); | 137 void ResetStateForRestart(); |
131 | 138 |
132 // Attach any credentials needed for the proxy server or origin server. | 139 // Attach any credentials needed for the proxy server or origin server. |
133 void ApplyAuth(); | 140 void ApplyAuth(); |
134 | 141 |
135 // Helper used by ApplyAuth(). Adds either the proxy auth header, or the | 142 // Helper used by ApplyAuth(). Adds either the proxy auth header, or the |
136 // origin server auth header, as specified by |target| | 143 // origin server auth header, as specified by |target| |
137 void AddAuthorizationHeader(HttpAuth::Target target); | 144 void AddAuthorizationHeader(HttpAuth::Target target); |
138 | 145 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // The number of bytes by which the header buffer is grown when it reaches | 245 // The number of bytes by which the header buffer is grown when it reaches |
239 // capacity. | 246 // capacity. |
240 enum { kHeaderBufInitialSize = 4096 }; | 247 enum { kHeaderBufInitialSize = 4096 }; |
241 | 248 |
242 // |kMaxHeaderBufSize| is the number of bytes that the response headers can | 249 // |kMaxHeaderBufSize| is the number of bytes that the response headers can |
243 // grow to. If the body start is not found within this range of the | 250 // grow to. If the body start is not found within this range of the |
244 // response, the transaction will fail with ERR_RESPONSE_HEADERS_TOO_BIG. | 251 // response, the transaction will fail with ERR_RESPONSE_HEADERS_TOO_BIG. |
245 // Note: |kMaxHeaderBufSize| should be a multiple of |kHeaderBufInitialSize|. | 252 // Note: |kMaxHeaderBufSize| should be a multiple of |kHeaderBufInitialSize|. |
246 enum { kMaxHeaderBufSize = 32768 }; // 32 kilobytes. | 253 enum { kMaxHeaderBufSize = 32768 }; // 32 kilobytes. |
247 | 254 |
| 255 // The size in bytes of the buffer we use to drain the response body that |
| 256 // we want to throw away. The response body is typically a small error |
| 257 // page just a few hundred bytes long. |
| 258 enum { kDrainBodyBufferSize = 1024 }; |
| 259 |
248 // The position where status line starts; -1 if not found yet. | 260 // The position where status line starts; -1 if not found yet. |
249 int header_buf_http_offset_; | 261 int header_buf_http_offset_; |
250 | 262 |
251 // Indicates the content length remaining to read. If this value is less | 263 // Indicates the content length remaining to read. If this value is less |
252 // than zero (and chunked_decoder_ is null), then we read until the server | 264 // than zero (and chunked_decoder_ is null), then we read until the server |
253 // closes the connection. | 265 // closes the connection. |
254 int64 content_length_; | 266 int64 content_length_; |
255 | 267 |
256 // Keeps track of the number of response body bytes read so far. | 268 // Keeps track of the number of response body bytes read so far. |
257 int64 content_read_; | 269 int64 content_read_; |
(...skipping 16 matching lines...) Expand all Loading... |
274 STATE_SSL_CONNECT_OVER_TUNNEL, | 286 STATE_SSL_CONNECT_OVER_TUNNEL, |
275 STATE_SSL_CONNECT_OVER_TUNNEL_COMPLETE, | 287 STATE_SSL_CONNECT_OVER_TUNNEL_COMPLETE, |
276 STATE_WRITE_HEADERS, | 288 STATE_WRITE_HEADERS, |
277 STATE_WRITE_HEADERS_COMPLETE, | 289 STATE_WRITE_HEADERS_COMPLETE, |
278 STATE_WRITE_BODY, | 290 STATE_WRITE_BODY, |
279 STATE_WRITE_BODY_COMPLETE, | 291 STATE_WRITE_BODY_COMPLETE, |
280 STATE_READ_HEADERS, | 292 STATE_READ_HEADERS, |
281 STATE_READ_HEADERS_COMPLETE, | 293 STATE_READ_HEADERS_COMPLETE, |
282 STATE_READ_BODY, | 294 STATE_READ_BODY, |
283 STATE_READ_BODY_COMPLETE, | 295 STATE_READ_BODY_COMPLETE, |
| 296 STATE_DRAIN_BODY_FOR_AUTH_RESTART, |
| 297 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, |
284 STATE_NONE | 298 STATE_NONE |
285 }; | 299 }; |
286 State next_state_; | 300 State next_state_; |
287 }; | 301 }; |
288 | 302 |
289 } // namespace net | 303 } // namespace net |
290 | 304 |
291 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ | 305 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
292 | 306 |
OLD | NEW |