Created
July 28, 2015 04:35
-
-
Save tstarling/f28f1da1eedd8a31b3bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/proxygen/lib/http/codec/HTTP1xCodec.cpp b/proxygen/lib/http/codec/HTTP1xCodec.cpp | |
index 3fb5205..f38a05e 100644 | |
--- a/proxygen/lib/http/codec/HTTP1xCodec.cpp | |
+++ b/proxygen/lib/http/codec/HTTP1xCodec.cpp | |
@@ -499,10 +499,13 @@ HTTP1xCodec::generateBody(IOBufQueue& writeBuf, | |
return 0; | |
} | |
size_t buflen = chain->computeChainDataLength(); | |
- if (buflen == 0) { | |
- return buflen; | |
- } | |
size_t totLen = buflen; | |
+ if (totLen == 0) { | |
+ if (eom) { | |
+ totLen += generateEOM(writeBuf, txn); | |
+ } | |
+ return totLen; | |
+ } | |
if (egressChunked_ && !inChunk_) { | |
char chunkLenBuf[32]; | |
@@ -586,11 +589,20 @@ size_t HTTP1xCodec::generateEOM(IOBufQueue& writeBuf, StreamID txn) { | |
size_t len = 0; | |
if (egressChunked_) { | |
CHECK(!inChunk_); | |
- if (!lastChunkWritten_) { | |
+ if (headRequest_ && | |
+ transportDirection_ == TransportDirection::DOWNSTREAM) { | |
lastChunkWritten_ = true; | |
- appendLiteral(writeBuf, len, "0\r\n"); | |
+ } else { | |
+ // appending a 0\r\n only if it's not a HEAD and downstream request | |
+ if (!lastChunkWritten_) { | |
+ lastChunkWritten_ = true; | |
+ if (!(headRequest_ && | |
+ transportDirection_ == TransportDirection::DOWNSTREAM)) { | |
+ appendLiteral(writeBuf, len, "0\r\n"); | |
+ } | |
+ } | |
+ appendLiteral(writeBuf, len, CRLF); | |
} | |
- appendLiteral(writeBuf, len, CRLF); | |
} | |
switch (transportDirection_) { | |
case TransportDirection::DOWNSTREAM: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment