proxygen
HPACKScheme.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 
16 
17 namespace proxygen { namespace compress {
18 
23  public:
24  explicit HPACKScheme(CompressionSimulator* sim, uint32_t tableSize)
25  : CompressionScheme(sim) {
31  allowOOO_ = (tableSize == 0);
32  }
33 
35  CHECK_EQ(serverQueue_.getQueuedBytes(), 0);
36  }
37 
38  // HPACK has no ACKs
39  std::unique_ptr<Ack> getAck(uint16_t /*seqn*/) override {
40  return nullptr;
41  }
42  void recvAck(std::unique_ptr<Ack> /*ack*/) override {
43  }
44 
45  std::pair<FrameFlags, std::unique_ptr<folly::IOBuf>> encode(
46  bool /*newPacket*/,
47  std::vector<compress::Header> allHeaders,
48  SimStats& stats) override {
49  auto block = client_.encode(allHeaders);
50  block->prepend(sizeof(uint16_t));
51  folly::io::RWPrivateCursor c(block.get());
52  c.writeBE<uint16_t>(index++);
55  // OOO is allowed with 0 table size
57  return {flags, std::move(block)};
58  }
59 
61  std::unique_ptr<folly::IOBuf> encodedReq,
62  SimStats& stats,
63  SimStreamingCallback& callback) override {
64  folly::io::Cursor cursor(encodedReq.get());
65  auto seqn = cursor.readBE<uint16_t>();
66  callback.seqn = seqn;
67  VLOG(1) << "Decoding request=" << callback.requestIndex
68  << " header seqn=" << seqn;
69  auto len = cursor.totalLength();
70  encodedReq->trimStart(sizeof(uint16_t));
72  seqn, std::move(encodedReq), len, &callback, flags.allowOOO);
73  callback.maybeMarkHolDelay();
76  }
77  }
78 
79  uint32_t getHolBlockCount() const override {
81  }
82 
86  bool allowOOO_{false};
87 };
88 }} // namespace proxygen::compress
flags
Definition: http_parser.h:127
void setDecoderHeaderTableMaxSize(uint32_t size)
Definition: HPACKCodec.h:58
void setEncoderHeaderTableSize(uint32_t size)
Definition: HPACKCodec.h:54
uint64_t getQueuedBytes() const
Definition: HPACKQueue.h:77
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void decode(FrameFlags flags, std::unique_ptr< folly::IOBuf > encodedReq, SimStats &stats, SimStreamingCallback &callback) override
Definition: HPACKScheme.h:60
HPACKScheme(CompressionSimulator *sim, uint32_t tableSize)
Definition: HPACKScheme.h:24
std::unique_ptr< Ack > getAck(uint16_t) override
Definition: HPACKScheme.h:39
void enqueueHeaderBlock(uint32_t seqn, std::unique_ptr< folly::IOBuf > block, size_t length, HPACK::StreamingCallback *streamingCb, bool oooOk)
Definition: HPACKQueue.h:26
uint32_t getHolBlockCount() const override
Definition: HPACKScheme.h:79
void setEncodeHeadroom(uint32_t headroom)
Definition: HeaderCodec.h:69
uint64_t getHolBlockCount() const
Definition: HPACKQueue.h:73
static const NoPathIndexingStrategy * getInstance()
void recvAck(std::unique_ptr< Ack >) override
Definition: HPACKScheme.h:42
std::pair< FrameFlags, std::unique_ptr< folly::IOBuf > > encode(bool, std::vector< compress::Header > allHeaders, SimStats &stats) override
Definition: HPACKScheme.h:45
void trimStart(std::size_t amount)
Definition: IOBuf.h:703
std::unique_ptr< folly::IOBuf > encode(std::vector< compress::Header > &headers) noexcept
Definition: HPACKCodec.cpp:48
char c
const HTTPHeaderSize & getEncodedSize()
Definition: HeaderCodec.h:62
void setHeaderIndexingStrategy(const HeaderIndexingStrategy *indexingStrat)
Definition: HPACKCodec.h:78