Skip to content

Commit 370a80b

Browse files
Shiv Kushwahfacebook-github-bot
authored andcommitted
Add knownLength to HTTPBinaryCodec parameter
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
1 parent f09499f commit 370a80b

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

proxygen/lib/http/codec/HTTPBinaryCodec.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ void encodeString(folly::StringPiece str, folly::io::QueueAppender& appender) {
3535
}
3636
} // namespace
3737

38-
HTTPBinaryCodec::HTTPBinaryCodec(TransportDirection direction) {
39-
transportDirection_ = direction;
40-
state_ = ParseState::FRAMING_INDICATOR;
41-
parseError_ = folly::none;
42-
parserPaused_ = false;
38+
HTTPBinaryCodec::HTTPBinaryCodec(TransportDirection direction)
39+
: HTTPBinaryCodec(direction, true) {
40+
}
41+
HTTPBinaryCodec::HTTPBinaryCodec(TransportDirection direction, bool knownLength)
42+
: knownLength_(knownLength),
43+
state_(ParseState::FRAMING_INDICATOR),
44+
parserPaused_(false),
45+
parseError_(folly::none),
46+
transportDirection_(direction) {
4347
}
4448

4549
HTTPBinaryCodec::~HTTPBinaryCodec() {

proxygen/lib/http/codec/HTTPBinaryCodec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class HTTPBinaryCodec : public HTTPCodec {
5454
public:
5555
// Default strictValidation to false for now to match existing behavior
5656
explicit HTTPBinaryCodec(TransportDirection direction);
57+
HTTPBinaryCodec(TransportDirection direction, bool knownLength);
5758
~HTTPBinaryCodec() override;
5859

5960
HTTPBinaryCodec(HTTPBinaryCodec&&) = default;

proxygen/lib/http/codec/test/HTTPBinaryCodecTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ class HTTPBinaryCodecForTest : public HTTPBinaryCodec {
2222
}
2323
explicit HTTPBinaryCodecForTest(TransportDirection direction,
2424
bool knownLength)
25-
: HTTPBinaryCodec{direction} {
26-
knownLength_ = knownLength;
25+
: HTTPBinaryCodec{direction, knownLength} {
2726
}
2827
ParseResult parseFramingIndicator(folly::io::Cursor& cursor,
2928
bool& request,

0 commit comments

Comments
 (0)