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 #ifndef NET_HTTP_HTTP_STREAM_PARSER_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_PARSER_H_ |
6 #define NET_HTTP_HTTP_STREAM_PARSER_H_ | 6 #define NET_HTTP_HTTP_STREAM_PARSER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 STATE_READ_HEADERS, | 87 STATE_READ_HEADERS, |
88 STATE_READ_HEADERS_COMPLETE, | 88 STATE_READ_HEADERS_COMPLETE, |
89 STATE_BODY_PENDING, | 89 STATE_BODY_PENDING, |
90 STATE_READ_BODY, | 90 STATE_READ_BODY, |
91 STATE_READ_BODY_COMPLETE, | 91 STATE_READ_BODY_COMPLETE, |
92 STATE_DONE | 92 STATE_DONE |
93 }; | 93 }; |
94 | 94 |
95 // The number of bytes by which the header buffer is grown when it reaches | 95 // The number of bytes by which the header buffer is grown when it reaches |
96 // capacity. | 96 // capacity. |
97 enum { kHeaderBufInitialSize = 4096 }; | 97 static const int kHeaderBufInitialSize = 4 * 1024; // 4K |
98 | 98 |
99 // |kMaxHeaderBufSize| is the number of bytes that the response headers can | 99 // |kMaxHeaderBufSize| is the number of bytes that the response headers can |
100 // grow to. If the body start is not found within this range of the | 100 // grow to. If the body start is not found within this range of the |
101 // response, the transaction will fail with ERR_RESPONSE_HEADERS_TOO_BIG. | 101 // response, the transaction will fail with ERR_RESPONSE_HEADERS_TOO_BIG. |
102 // Note: |kMaxHeaderBufSize| should be a multiple of |kHeaderBufInitialSize|. | 102 // Note: |kMaxHeaderBufSize| should be a multiple of |kHeaderBufInitialSize|. |
103 enum { kMaxHeaderBufSize = 256 * 1024 }; // 256 kilobytes. | 103 static const int kMaxHeaderBufSize = kHeaderBufInitialSize * 64; // 256K |
104 | 104 |
105 // The maximum sane buffer size. | 105 // The maximum sane buffer size. |
106 enum { kMaxBufSize = 2 * 1024 * 1024 }; // 2 megabytes. | 106 static const int kMaxBufSize = 2 * 1024 * 1024; // 2M |
107 | 107 |
108 // Handle callbacks. | 108 // Handle callbacks. |
109 void OnIOComplete(int result); | 109 void OnIOComplete(int result); |
110 | 110 |
111 // Try to make progress sending/receiving the request/response. | 111 // Try to make progress sending/receiving the request/response. |
112 int DoLoop(int result); | 112 int DoLoop(int result); |
113 | 113 |
114 // The implementations of each state of the state machine. | 114 // The implementations of each state of the state machine. |
115 int DoSendHeaders(int result); | 115 int DoSendHeaders(int result); |
116 int DoSendBody(int result); | 116 int DoSendBody(int result); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 size_t chunk_length_; | 197 size_t chunk_length_; |
198 size_t chunk_length_without_encoding_; | 198 size_t chunk_length_without_encoding_; |
199 bool sent_last_chunk_; | 199 bool sent_last_chunk_; |
200 | 200 |
201 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); | 201 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); |
202 }; | 202 }; |
203 | 203 |
204 } // namespace net | 204 } // namespace net |
205 | 205 |
206 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ | 206 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ |
OLD | NEW |