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: Ignore Content-Length for methods without payload semantics #428

Merged
merged 1 commit into from
Feb 14, 2025
Merged

Conversation

0x676e67
Copy link
Owner

@0x676e67 0x676e67 commented Feb 14, 2025

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 and src/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 the add_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 from POST to GET in the example to demonstrate a different type of request.

Enhancements to header management:

  • src/util/client/request.rs: Updated the body method to include the HTTP method when adding the Content-Length header, ensuring that headers are sorted correctly based on the method and order.
  • src/util/client/request.rs: Modified the add_content_length_header function to accept the HTTP method as a parameter and check if the method has defined payload semantics before adding the Content-Length header.

New utility functions:

  • src/util/client/request.rs: Added the method_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 the map_alpn_protos function to map HTTP versions to ALPN protocols, enhancing protocol handling.

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.

1 participant