Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: net/http/http_stream_parser.h

Issue 9270030: net: Don't merge HTTP headers and body if the body is not in memory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
wtc 2012/01/24 19:08:04 Note: 'request' consists of 'request headers' and
95 // small enough and the body is in memory, and not chunked).
96 static bool ShouldMerge(const std::string& request,
wtc 2012/01/24 19:08:04 The 'request' parameter should be renamed 'request
satorux1 2012/01/24 19:25:42 I like the idea and chose the latter.
97 const UploadDataStream* request_body);
98
94 // The number of extra bytes required to encode a chunk. 99 // The number of extra bytes required to encode a chunk.
95 static const size_t kChunkHeaderFooterSize; 100 static const size_t kChunkHeaderFooterSize;
96 101
97 private: 102 private:
98 // FOO_COMPLETE states implement the second half of potentially asynchronous 103 // FOO_COMPLETE states implement the second half of potentially asynchronous
99 // operations and don't necessarily mean that FOO is complete. 104 // operations and don't necessarily mean that FOO is complete.
100 enum State { 105 enum State {
101 STATE_NONE, 106 STATE_NONE,
102 STATE_SENDING_HEADERS, 107 STATE_SENDING_HEADERS,
103 // If the request comes with a body, either of the following two 108 // If the request comes with a body, either of the following two
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 size_t chunk_length_; 228 size_t chunk_length_;
224 size_t chunk_length_without_encoding_; 229 size_t chunk_length_without_encoding_;
225 bool sent_last_chunk_; 230 bool sent_last_chunk_;
226 231
227 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser); 232 DISALLOW_COPY_AND_ASSIGN(HttpStreamParser);
228 }; 233 };
229 234
230 } // namespace net 235 } // namespace net
231 236
232 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_ 237 #endif // NET_HTTP_HTTP_STREAM_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698