summaryrefslogtreecommitdiffstats
path: root/net/spdy/hpack_decoder.h
diff options
context:
space:
mode:
authorjgraettinger@chromium.org <jgraettinger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 22:44:20 +0000
committerjgraettinger@chromium.org <jgraettinger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 22:44:20 +0000
commite99d1287191bfdaad3448b7080b46ae39fb6c97a (patch)
tree698ac0b24d0fcb795aa08cc5ab18f61dda751616 /net/spdy/hpack_decoder.h
parent630e8545ebed7170f0b0d263c9312a0594710a58 (diff)
downloadchromium_src-e99d1287191bfdaad3448b7080b46ae39fb6c97a.zip
chromium_src-e99d1287191bfdaad3448b7080b46ae39fb6c97a.tar.gz
chromium_src-e99d1287191bfdaad3448b7080b46ae39fb6c97a.tar.bz2
Implement a minimal decoder for HPACK (HTTP/2 compression)
The decoder assumes everything is encoded as literals without indexing and does not use Huffman encoding. The decoder will be expanded to handle everything in the spec in future CLs. This lands server change 60496510 by akalin. BUG=339578 Review URL: https://codereview.chromium.org/150453002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248064 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/hpack_decoder.h')
-rw-r--r--net/spdy/hpack_decoder.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/net/spdy/hpack_decoder.h b/net/spdy/hpack_decoder.h
new file mode 100644
index 0000000..3230fde
--- /dev/null
+++ b/net/spdy/hpack_decoder.h
@@ -0,0 +1,64 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_SPDY_HPACK_DECODER_H_
+#define NET_SPDY_HPACK_DECODER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/macros.h"
+#include "base/strings/string_piece.h"
+#include "net/base/net_export.h"
+#include "net/spdy/hpack_encoding_context.h"
+#include "net/spdy/hpack_input_stream.h" // For HpackHeaderPairVector.
+
+namespace net {
+
+// An HpackDecoder decodes header sets as outlined in
+// http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05
+// .
+class NET_EXPORT_PRIVATE HpackDecoder {
+ public:
+ explicit HpackDecoder(uint32 max_string_literal_size);
+ ~HpackDecoder();
+
+ // Decodes the given string into the given header set. Returns
+ // whether or not the decoding was successful.
+ //
+ // TODO(akalin): Emit the headers via a callback/delegate instead of
+ // putting them into a vector.
+ bool DecodeHeaderSet(base::StringPiece input,
+ HpackHeaderPairVector* header_list);
+
+ // Accessors for testing.
+
+ bool DecodeNextNameForTest(HpackInputStream* input_stream,
+ base::StringPiece* next_name) {
+ return DecodeNextName(input_stream, next_name);
+ }
+
+ private:
+ const uint32 max_string_literal_size_;
+ HpackEncodingContext context_;
+
+ // Tries to process the next header representation and maybe emit
+ // headers into |header_list| according to it. Returns true if
+ // successful, or false if an error was encountered.
+ bool ProcessNextHeaderRepresentation(
+ HpackInputStream* input_stream,
+ HpackHeaderPairVector* header_list);
+
+ bool DecodeNextName(HpackInputStream* input_stream,
+ base::StringPiece* next_name);
+ bool DecodeNextValue(HpackInputStream* input_stream,
+ base::StringPiece* next_name);
+
+ DISALLOW_COPY_AND_ASSIGN(HpackDecoder);
+};
+
+} // namespace net
+
+#endif // NET_SPDY_HPACK_DECODER_H_