Skip to content
New issue

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

Fix no content-length #814

Merged
merged 2 commits into from Sep 21, 2022
Merged

Fix no content-length #814

merged 2 commits into from Sep 21, 2022

Conversation

Yurunsoft
Copy link
Contributor

RFC 允许不带上 content-length 请求头

https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2

image

另外是否可以考虑增加自动化测试,比如 Github Actions,这样修改了东西可以跑一遍看看测试用例是否都通过,增加新功能、修复 bug 也可以增加测试用例。

@walkor
Copy link
Owner

walkor commented Sep 21, 2022

客户端可以带content-length,典型的post请求会带content-length,一些软件如postman还允许GET请求带content-length。
自动化测试一直想弄来着,但是手上总有其它事情,一直耽搁着

@Yurunsoft
Copy link
Contributor Author

确实会有不带 content-length 的客户端,最好还是兼容一下,毕竟也是 RFC 允许的。

我之前提的 #583 好像已经被解决了

@walkor
Copy link
Owner

walkor commented Sep 21, 2022

对于POST PUT PATCH 请求,即使没有content-length,也要有Transfer-Encoding: chunked,通过chunked格式来判读整个包的长度。目前workerman不支持 Transfer-Encoding: chunked 的请求,主要是解析起来有些麻烦。
还有就是目前为止没碰到过POST PUT PATCH 请求不带content-length的。
如果这个PR合并,也其实只是忽略了content-length头,并没有解析出请求的具体长度,真遇到Transfer-Encoding: chunked的请求反而有body缺失问题。

@Yurunsoft
Copy link
Contributor Author

加个判断,没有 content-length 但是有 Transfer-Encoding: chunked 就返回 400 呢

@walkor
Copy link
Owner

walkor commented Sep 21, 2022

也可以

@walkor
Copy link
Owner

walkor commented Sep 21, 2022

有Transfer-Encoding的直接400

…-Encoding, the response http status code 400
@walkor walkor merged commit 42ea1da into walkor:4.1 Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants