| 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_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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // be large enough to store the encoded chunk, which is payload.size() + | 84 // be large enough to store the encoded chunk, which is payload.size() + |
| 85 // kChunkHeaderFooterSize. Returns ERR_INVALID_ARGUMENT if |output_size| | 85 // kChunkHeaderFooterSize. Returns ERR_INVALID_ARGUMENT if |output_size| |
| 86 // is not large enough. | 86 // is not large enough. |
| 87 // | 87 // |
| 88 // The output will look like: "HEX\r\n[payload]\r\n" | 88 // The output will look like: "HEX\r\n[payload]\r\n" |
| 89 // where HEX is a length in hexdecimal (without the "0x" prefix). | 89 // where HEX is a length in hexdecimal (without the "0x" prefix). |
| 90 static int EncodeChunk(const base::StringPiece& payload, | 90 static int EncodeChunk(const base::StringPiece& payload, |
| 91 char* output, | 91 char* output, |
| 92 size_t output_size); | 92 size_t output_size); |
| 93 | 93 |
| 94 // Returns true if request and body should be merged (i.e. the sum is | 94 // Returns true if request headers and body should be merged (i.e. the |
| 95 // small enough and the body is in memory, and not chunked). | 95 // sum is small enough and the body is in memory, and not chunked). |
| 96 static bool ShouldMerge(const std::string& request, | 96 static bool ShouldMergeRequestHeadersAndBody( |
| 97 const UploadDataStream* request_body); | 97 const std::string& request_headers, |
| 98 const UploadDataStream* request_body); |
| 98 | 99 |
| 99 // The number of extra bytes required to encode a chunk. | 100 // The number of extra bytes required to encode a chunk. |
| 100 static const size_t kChunkHeaderFooterSize; | 101 static const size_t kChunkHeaderFooterSize; |
| 101 | 102 |
| 102 private: | 103 private: |
| 103 // FOO_COMPLETE states implement the second half of potentially asynchronous | 104 // FOO_COMPLETE states implement the second half of potentially asynchronous |
| 104 // operations and don't necessarily mean that FOO is complete. | 105 // operations and don't necessarily mean that FOO is complete. |
| 105 enum State { | 106 enum State { |
| 106 STATE_NONE, | 107 STATE_NONE, |
| 107 STATE_SENDING_HEADERS, | 108 STATE_SENDING_HEADERS, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 size_t chunk_length_; | 229 size_t chunk_length_; |
| 229 size_t chunk_length_without_encoding_; | 230 size_t chunk_length_without_encoding_; |
| 230 bool sent_last_chunk_; | 231 bool sent_last_chunk_; |
| 231 | 232 |
| 232 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); | 233 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); |
| 233 }; | 234 }; |
| 234 | 235 |
| 235 } // namespace net | 236 } // namespace net |
| 236 | 237 |
| 237 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ | 238 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ |
| OLD | NEW |