proxygen
GzipHeaderCodec.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
12 #include <folly/Expected.h>
13 #include <folly/ThreadLocal.h>
14 #include <folly/io/Cursor.h>
15 #include <folly/io/IOBuf.h>
16 #include <map>
17 #include <memory>
20 #include <zlib.h>
21 
22 namespace proxygen {
23 
24 enum class GzipDecodeError : uint8_t {
25  NONE = 0,
26  BAD_ENCODING = 1,
32 };
33 
34 class GzipHeaderCodec : public HeaderCodec {
35 
36  public:
37  GzipHeaderCodec(int compressionLevel,
38  const SPDYVersionSettings& versionSettings);
39  explicit GzipHeaderCodec(int compressionLevel,
41  ~GzipHeaderCodec() override;
42 
43  std::unique_ptr<folly::IOBuf> encode(
44  std::vector<compress::Header>& headers) noexcept;
45 
47  decode(folly::io::Cursor& cursor, uint32_t length) noexcept;
48 
53  return decodedSize_;
54  }
55 
56  private:
57  folly::IOBuf& getHeaderBuf();
58 
63  parseNameValues(const folly::IOBuf& uncompressed,
64  uint32_t uncompressedLength) noexcept;
65 
67  z_stream deflater_;
68  z_stream inflater_;
71 };
72 }
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
TokenBindingMessage decode(folly::io::Cursor &cursor)
Definition: Types.cpp:132
const SPDYVersionSettings & versionSettings_
requires E e noexcept(noexcept(s.error(std::move(e))))
ProtocolVersion version
std::deque< HeaderPiece > HeaderPieceList
Definition: HeaderPiece.h:59
compress::HeaderPieceList outHeaders_
const HTTPHeaderSize & getDecodedSize()