proxygen
TestStreamingCallback.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 
13 #include <folly/Expected.h>
14 #include <folly/Function.h>
15 
16 namespace proxygen {
17 
19  public:
21  const folly::fbstring& value) override {
22  headers.emplace_back(duplicate(name), name.size(), true, false);
23  headers.emplace_back(duplicate(value), value.size(), true, false);
24  }
25  void onHeadersComplete(HTTPHeaderSize /*decodedSize*/) override {
26  if (headersCompleteCb) {
28  }
29  }
30  void onDecodeError(HPACK::DecodeError decodeError) override {
31  error = decodeError;
32  }
33 
34  void reset() {
35  headers.clear();
37  }
38 
41  return HeaderDecodeResult{headers, 0};
42  } else {
44  }
45  }
46 
47  bool hasError() const {
49  }
50 
51  std::unique_ptr<std::vector<HPACKHeader>> hpackHeaders() const {
52  CHECK(!hasError());
53  auto result = std::make_unique<std::vector<HPACKHeader>>();
54  for (size_t i = 0; i < headers.size(); i += 2) {
55  result->emplace_back(headers[i].str, headers[i + 1].str);
56  }
57 
58  return result;
59  }
60 
61 
64  char* duplicate(const folly::fbstring& str) {
65  char* res = CHECK_NOTNULL(new char[str.length() + 1]);
66  memcpy(res, str.data(), str.length() + 1);
67  return res;
68  }
69 
71 };
72 
73 }
size_type size() const
Definition: FBString.h:1337
std::unique_ptr< std::vector< HPACKHeader > > hpackHeaders() const
void onHeadersComplete(HTTPHeaderSize) override
char * duplicate(const folly::fbstring &str)
void onHeader(const folly::fbstring &name, const folly::fbstring &value) override
void onDecodeError(HPACK::DecodeError decodeError) override
folly::Function< void()> headersCompleteCb
const char * name
Definition: http_parser.c:437
const value_type * data() const
Definition: FBString.h:1716
std::deque< HeaderPiece > HeaderPieceList
Definition: HeaderPiece.h:59
constexpr Unexpected< typename std::decay< Error >::type > makeUnexpected(Error &&)
Definition: Expected.h:785
static const char *const value
Definition: Conv.cpp:50
compress::HeaderPieceList headers
folly::Expected< HeaderDecodeResult, HPACK::DecodeError > getResult()
size_type length() const
Definition: FBString.h:1341