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

Unified Diff: net/http/http_stream_parser.h

Issue 9242018: Factor out chunk encoding logic into HttpStreamParser::EncodeChunk(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add NET_EXPORT_PRIVATE to fix windows builds 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_stream_parser.h
diff --git a/net/http/http_stream_parser.h b/net/http/http_stream_parser.h
index ae9fc3e3ed5cfcb151ec3525a4b6da2b5a367298..1d03a259ad0fdeeb15ef37a6f3b9b7a8a79e1bb2 100644
--- a/net/http/http_stream_parser.h
+++ b/net/http/http_stream_parser.h
@@ -9,7 +9,9 @@
#include <string>
#include "base/basictypes.h"
+#include "base/string_piece.h"
#include "net/base/completion_callback.h"
+#include "net/base/net_export.h"
#include "net/base/net_log.h"
#include "net/base/upload_data_stream.h"
#include "net/http/http_chunked_decoder.h"
@@ -26,7 +28,7 @@ class IOBuffer;
class SSLCertRequestInfo;
class SSLInfo;
-class HttpStreamParser : public ChunkCallback {
+class NET_EXPORT_PRIVATE HttpStreamParser : public ChunkCallback {
public:
// Any data in |read_buffer| will be used before reading from the socket
// and any data left over after parsing the stream will be put into
@@ -77,6 +79,21 @@ class HttpStreamParser : public ChunkCallback {
// ChunkCallback methods.
virtual void OnChunkAvailable() OVERRIDE;
+ // Encodes the given |payload| in the chunked format to |output|.
+ // Returns the number of bytes written to |output|. |output_size| should
+ // be large enough to store the encoded chunk, which is payload.size() +
+ // kChunkHeaderFooterSize. Returns ERR_INVALID_ARGUMENT if |output_size|
+ // is not large enough.
+ //
+ // The output will look like: "HEX\r\n[payload]\r\n"
+ // where HEX is a length in hexdecimal (without the "0x" prefix).
+ static int EncodeChunk(const base::StringPiece& payload,
+ char* output,
+ size_t output_size);
+
+ // The number of extra bytes required to encode a chunk.
+ static const size_t kChunkHeaderFooterSize;
+
private:
// FOO_COMPLETE states implement the second half of potentially asynchronous
// operations and don't necessarily mean that FOO is complete.

Powered by Google App Engine
This is Rietveld 408576698