Skip to content

Commit

Permalink
Add knownLength to HTTPBinaryCodec parameter
Browse files Browse the repository at this point in the history
Summary: We need to allow callers who instantiate this class to set the knownLength parameter to construct chunked requests.

Differential Revision: D68312239

fbshipit-source-id: d14aae172f1eca8af133a23ef04176206b65c363
  • Loading branch information
Shiv Kushwah authored and facebook-github-bot committed Jan 17, 2025
1 parent f09499f commit 370a80b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions proxygen/lib/http/codec/HTTPBinaryCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ void encodeString(folly::StringPiece str, folly::io::QueueAppender& appender) {
}
} // namespace

HTTPBinaryCodec::HTTPBinaryCodec(TransportDirection direction) {
transportDirection_ = direction;
state_ = ParseState::FRAMING_INDICATOR;
parseError_ = folly::none;
parserPaused_ = false;
HTTPBinaryCodec::HTTPBinaryCodec(TransportDirection direction)
: HTTPBinaryCodec(direction, true) {
}
HTTPBinaryCodec::HTTPBinaryCodec(TransportDirection direction, bool knownLength)
: knownLength_(knownLength),
state_(ParseState::FRAMING_INDICATOR),
parserPaused_(false),
parseError_(folly::none),
transportDirection_(direction) {
}

HTTPBinaryCodec::~HTTPBinaryCodec() {
Expand Down
1 change: 1 addition & 0 deletions proxygen/lib/http/codec/HTTPBinaryCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class HTTPBinaryCodec : public HTTPCodec {
public:
// Default strictValidation to false for now to match existing behavior
explicit HTTPBinaryCodec(TransportDirection direction);
HTTPBinaryCodec(TransportDirection direction, bool knownLength);
~HTTPBinaryCodec() override;

HTTPBinaryCodec(HTTPBinaryCodec&&) = default;
Expand Down
3 changes: 1 addition & 2 deletions proxygen/lib/http/codec/test/HTTPBinaryCodecTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class HTTPBinaryCodecForTest : public HTTPBinaryCodec {
}
explicit HTTPBinaryCodecForTest(TransportDirection direction,
bool knownLength)
: HTTPBinaryCodec{direction} {
knownLength_ = knownLength;
: HTTPBinaryCodec{direction, knownLength} {
}
ParseResult parseFramingIndicator(folly::io::Cursor& cursor,
bool& request,
Expand Down

0 comments on commit 370a80b

Please sign in to comment.