We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用nginx代理websocket时发现hv在回复101时Content-Length为0,导致nginx将连接关闭。 做了两处修改,请 @ithewei 帮忙review下 1、 文件:HttpMessage.h 代码:
size_t ContentLength() { if (content_length == 0) { FillContentLength(); } return content_length; }
改为:
size_t ContentLength() { if (content_length == 0 && !IsUpgrade()) { FillContentLength(); } return content_length; }
2、 文件:HttpMessage.cpp 代码:
void HttpMessage::FillContentLength() { auto iter = headers.find("Content-Length"); if (iter != headers.end()) { content_length = atoll(iter->second.c_str()); } if (content_length == 0) { DumpBody(); content_length = body.size(); } if (iter == headers.end() && !IsChunked() && content_type != TEXT_EVENT_STREAM) { if (content_length != 0 || type == HTTP_RESPONSE) { headers["Content-Length"] = hv::to_string(content_length); } } }
void HttpMessage::FillContentLength() { auto iter = headers.find("Content-Length"); if (iter != headers.end()) { content_length = atoll(iter->second.c_str()); } if (content_length == 0) { DumpBody(); content_length = body.size(); } if (iter == headers.end() && !IsChunked() && content_type != TEXT_EVENT_STREAM) { if ((content_length != 0 || type == HTTP_RESPONSE) && !IsUpgrade()) { headers["Content-Length"] = hv::to_string(content_length); } } }
The text was updated successfully, but these errors were encountered:
只改第二处就可以了, 另外应该是if (content_length != 0 || (type == HTTP_RESPONSE && !IsUpgrade()) content_length不等于0,无论如何都需要设置Content-Length头部
if (content_length != 0 || (type == HTTP_RESPONSE && !IsUpgrade())
Content-Length
Sorry, something went wrong.
No branches or pull requests
使用nginx代理websocket时发现hv在回复101时Content-Length为0,导致nginx将连接关闭。
做了两处修改,请 @ithewei 帮忙review下
1、
文件:HttpMessage.h
代码:
改为:
2、
文件:HttpMessage.cpp
代码:
改为:
The text was updated successfully, but these errors were encountered: