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 #include "net/spdy/hpack_encoder.h"
7 #include "net/spdy/hpack_output_stream.h"
13 HpackEncoder::HpackEncoder(uint32 max_string_literal_size
)
14 : max_string_literal_size_(max_string_literal_size
) {}
16 HpackEncoder::~HpackEncoder() {}
18 bool HpackEncoder::EncodeHeaderSet(const std::map
<string
, string
>& header_set
,
20 // TOOD(akalin): Do more sophisticated encoding.
21 HpackOutputStream
output_stream(max_string_literal_size_
);
22 for (std::map
<string
, string
>::const_iterator it
= header_set
.begin();
23 it
!= header_set
.end(); ++it
) {
24 // TODO(akalin): Clarify in the spec that encoding with the name
25 // as a literal is OK even if the name already exists in the
27 if (!output_stream
.AppendLiteralHeaderNoIndexingWithName(
28 it
->first
, it
->second
)) {
32 output_stream
.TakeString(output
);