1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_SPDY_HPACK_DECODER_H_
6 #define NET_SPDY_HPACK_DECODER_H_
11 #include "base/basictypes.h"
12 #include "base/macros.h"
13 #include "base/strings/string_piece.h"
14 #include "net/base/net_export.h"
15 #include "net/spdy/hpack_encoding_context.h"
16 #include "net/spdy/hpack_input_stream.h" // For HpackHeaderPairVector.
20 // An HpackDecoder decodes header sets as outlined in
21 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05
23 class NET_EXPORT_PRIVATE HpackDecoder {
25 explicit HpackDecoder(uint32 max_string_literal_size);
28 // Decodes the given string into the given header set. Returns
29 // whether or not the decoding was successful.
31 // TODO(akalin): Emit the headers via a callback/delegate instead of
32 // putting them into a vector.
33 bool DecodeHeaderSet(base::StringPiece input,
34 HpackHeaderPairVector* header_list);
36 // Accessors for testing.
38 bool DecodeNextNameForTest(HpackInputStream* input_stream,
39 base::StringPiece* next_name) {
40 return DecodeNextName(input_stream, next_name);
44 const uint32 max_string_literal_size_;
45 HpackEncodingContext context_;
47 // Tries to process the next header representation and maybe emit
48 // headers into |header_list| according to it. Returns true if
49 // successful, or false if an error was encountered.
50 bool ProcessNextHeaderRepresentation(
51 HpackInputStream* input_stream,
52 HpackHeaderPairVector* header_list);
54 bool DecodeNextName(HpackInputStream* input_stream,
55 base::StringPiece* next_name);
56 bool DecodeNextValue(HpackInputStream* input_stream,
57 base::StringPiece* next_name);
59 DISALLOW_COPY_AND_ASSIGN(HpackDecoder);
64 #endif // NET_SPDY_HPACK_DECODER_H_