Remove Content-Length header when chunked reply is used, only close connection when Content-Length is unknown.
Change-Id: I12726fb8b08417f7e7b429f525ee2c7980f22375
This commit is contained in:
parent
9cd08e3a77
commit
5860719ec7
1 changed files with 11 additions and 1 deletions
|
@ -284,8 +284,18 @@ void HTTP::Parser::StartResponse(std::string code, std::string message, const HT
|
|||
protocol = prot;
|
||||
if (sendingChunks){
|
||||
SetHeader("Transfer-Encoding", "chunked");
|
||||
//Chunked encoding does not allow a Content-Length, so convert to Content-Range instead
|
||||
if (headers.count("Content-Length")){
|
||||
uint32_t len = atoi(headers["Content-Length"].c_str());
|
||||
if (len && !headers.count("Content-Range")){
|
||||
std::stringstream rangeReply;
|
||||
rangeReply << "bytes 0-" << (len-1) << "/" << len;
|
||||
SetHeader("Content-Range", rangeReply.str());
|
||||
}
|
||||
headers.erase("Content-Length");
|
||||
}
|
||||
}else{
|
||||
SetHeader("Connection", "close");
|
||||
if (!headers.count("Content-Length")){SetHeader("Connection", "close");}
|
||||
}
|
||||
bufferChunks = bufferAllChunks;
|
||||
if (!bufferAllChunks){SendResponse(code, message, conn);}
|
||||
|
|
Loading…
Add table
Reference in a new issue