70 headers_ = std::make_unique<HTTPMessage>();
78 headers_ = std::make_unique<HTTPMessage>();
87 CHECK(
headers_) <<
"You need to call `status` before adding headers";
88 headers_->getHeaders().add(headerIn, value);
94 CHECK(
headers_) <<
"You need to call `status` before adding headers";
95 headers_->getHeaders().add(code, value);
111 template <
typename T>
114 folly::to<std::string>(std::forward<T>(
t))));
149 const auto len =
body_ ?
body_->computeChainDataLength() : 0;
152 folly::to<std::string>(len));
188 headers_ = std::make_unique<HTTPMessage>();
190 headers_->constructDirectResponse({1, 1}, 200,
"OK");
192 CHECK(!upgradeProtocol.empty());
193 headers_->constructDirectResponse({1, 1}, 101,
"Switching Protocols");
201 headers_ = std::make_unique<HTTPMessage>();
202 headers_->constructDirectResponse({1, 1}, 400,
"Bad Request");
208 headers_->setEgressWebsocketUpgrade();
216 std::unique_ptr<folly::IOBuf>
body_;
virtual void sendChunkTerminator() noexcept=0
ResponseBuilder & status(uint16_t code, const std::string &message)
void acceptUpgradeRequest(UpgradeType upgradeType, const std::string upgradeProtocol="")
void rejectUpgradeRequest()
virtual void sendEOM() noexcept=0
virtual void sendTrailers(const HTTPHeaders &trailers)
constexpr detail::Map< Move > move
HTTPTransaction * getTransaction() const noexcept
std::unique_ptr< folly::IOBuf > body_
virtual void sendChunkHeader(size_t len) noexcept=0
ResponseBuilder & body(std::unique_ptr< folly::IOBuf > bodyIn)
ResponseBuilder & setEgressWebsocketHeaders()
ResponseBuilder & header(HTTPHeaderCode code, const T &value)
ResponseHandler *const txn_
virtual void sendHeaders(HTTPMessage &msg) noexcept=0
ResponseBuilder & header(const std::string &headerIn, const T &value)
ResponseBuilder & trailers(const HTTPHeaders &trailers)
ResponseBuilder & promise(const std::string &url, const std::string &host)
virtual void sendBody(std::unique_ptr< folly::IOBuf > body) noexcept=0
static const char *const value
ResponseBuilder(ResponseHandler *txn)
ResponseBuilder & closeConnection()
std::unique_ptr< HTTPMessage > headers_
std::unique_ptr< HTTPHeaders > trailers_
ResponseBuilder & body(T &&t)
Chunked chunked(const Container &container, int chunkSize=256)
static std::unique_ptr< IOBuf > maybeCopyBuffer(const std::string &buf, std::size_t headroom=0, std::size_t minTailroom=0)