blob: 3230fded7e91f3f661ee290e92845b469592a729 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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_
|