fix: Ignore Content-Length for methods without payload semantics #428
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.
Tracing line: https://github.com/hyperium/hyper/blob/621d8e4d7788bfd2d62d15d40a73efae7f9a0bf0/src/proto/h2/client.rs#L664
This pull request includes several changes to the
examples/headers_order.rs
andsrc/util/client/request.rs
files to improve the handling of HTTP requests and headers. The most important changes include modifying the request method in the example, updating theadd_content_length_header
function to consider the HTTP method, and introducing a new utility function to check method payload semantics.Improvements to HTTP request handling:
examples/headers_order.rs
: Changed the request method fromPOST
toGET
in the example to demonstrate a different type of request.Enhancements to header management:
src/util/client/request.rs
: Updated thebody
method to include the HTTP method when adding theContent-Length
header, ensuring that headers are sorted correctly based on the method and order.src/util/client/request.rs
: Modified theadd_content_length_header
function to accept the HTTP method as a parameter and check if the method has defined payload semantics before adding theContent-Length
header.New utility functions:
src/util/client/request.rs
: Added themethod_has_defined_payload_semantics
function to determine if an HTTP method has defined payload semantics, improving the accuracy of header management.src/util/client/request.rs
: Introduced themap_alpn_protos
function to map HTTP versions to ALPN protocols, enhancing protocol handling.