1
#pragma once
2

            
3
#include <cstdint>
4
#include <queue>
5
#include <string>
6
#include <vector>
7

            
8
#include "envoy/http/codec.h"
9

            
10
#include "source/common/buffer/buffer_impl.h"
11
#include "source/common/common/c_smart_ptr.h"
12
#include "source/common/common/logger.h"
13

            
14
#include "quiche/http2/adapter/data_source.h"
15
#include "quiche/http2/hpack/hpack_encoder.h"
16

            
17
namespace Envoy {
18
namespace Http {
19
namespace Http2 {
20

            
21
/**
22
 * A class that creates and sends METADATA payloads. A METADATA payload is a
23
 * group of string key value pairs encoded in HTTP/2 header blocks. METADATA
24
 * frames are constructed in two steps: first, the stream submits the
25
 * MetadataMapVector to the encoder, and later, the MetadataSources generate
26
 * frame payloads for transmission on the wire.
27
 */
28
class NewMetadataEncoder : Logger::Loggable<Logger::Id::http2> {
29
public:
30
  using MetadataSourceVector = std::vector<std::unique_ptr<http2::adapter::MetadataSource>>;
31
  NewMetadataEncoder();
32

            
33
  /**
34
   * Creates wire format HTTP/2 header block from a vector of metadata maps.
35
   * @param metadata_map_vector supplies the metadata map vector to encode.
36
   * @return whether encoding is successful.
37
   */
38
  MetadataSourceVector createSources(const MetadataMapVector& metadata_map_vector);
39

            
40
private:
41
  std::unique_ptr<http2::adapter::MetadataSource> createSource(const MetadataMap& metadata_map);
42

            
43
  spdy::HpackEncoder deflater_;
44
};
45

            
46
} // namespace Http2
47
} // namespace Http
48
} // namespace Envoy