Skip to content

Commit

Permalink
[XrdHttp] Avoid sending empty header in the response as this conflict…
Browse files Browse the repository at this point in the history
…s with the reported content-length
  • Loading branch information
esindril authored and amadio committed Mar 21, 2023
1 parent a40e187 commit 3944814
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/XrdHttp/XrdHttpProtocol.cc
Expand Up @@ -1529,7 +1529,7 @@ int XrdHttpProtocol::StartSimpleResp(int code, const char *desc, const char *hea
if ((bodylen >= 0) && (code != 100))
ss << "Content-Length: " << bodylen << crlf;

if (header_to_add)
if (header_to_add && (header_to_add[0] != '\0'))
ss << header_to_add << crlf;

ss << crlf;
Expand All @@ -1548,13 +1548,13 @@ int XrdHttpProtocol::StartSimpleResp(int code, const char *desc, const char *hea

int XrdHttpProtocol::StartChunkedResp(int code, const char *desc, const char *header_to_add, bool keepalive) {
const std::string crlf = "\r\n";

std::stringstream ss;
if (header_to_add) {

if (header_to_add && (header_to_add[0] != '\0')) {
ss << header_to_add << crlf;
}
ss << "Transfer-Encoding: chunked";

ss << "Transfer-Encoding: chunked";
TRACEI(RSP, "Starting chunked response");
return StartSimpleResp(code, desc, ss.str().c_str(), -1, keepalive);
}
Expand Down

0 comments on commit 3944814

Please sign in to comment.