fix(awc): some request methods incorrectly send body & body-headers #3705
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.
PR Type
Bug Fix
PR Checklist
Overview
The existing implementation for awc incorrectly sends a request-body for http methods that don't support one, such as
GET/HEAD/OPTIONS/TRACE
. This is especially apparent when passing a stream into the request for all methods since it uses chunked content-encoding.I discovered this whilst implementing a reverse-proxy using actix-web and awc.
Example:
You can verify this yourself with a simple script (I'm using netcat to view the request
nc -lvp 8000
):The following changes ensure that the body and its associated headers are not included for the standard request methods, resulting in a correct request: