fix(transport): check if body is empty before get Content-Type decoder #3654
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If body is empty, we cannot get Content-Type, and will return a CODEC error
Close #3653
Description (what this PR does / why we need it):
默认的http.DefaultRequestDecoder会根据请求的Content-Type获取codec,但是body为空,请求头可能不会携带Content-Type这个header,因此服务会响应
unregister Content-Type:
的错误。我把body为空的校验调整到了获取Content-Type之前,避免这种情况出现错误。
Which issue(s) this PR fixes (resolves / be part of):
fixes #3653
Other special notes for the reviewers: