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: Ensure HTTP version negotiation for non-TLS requests #397

Merged
merged 2 commits into from
Feb 5, 2025
Merged

Conversation

0x676e67
Copy link
Owner

@0x676e67 0x676e67 commented Feb 5, 2025

This pull request includes changes to improve HTTP version handling and testing in the rquest library. The most important changes include modifying the request version handling, adding new tests for HTTP versions, and removing outdated tests.

Improvements to HTTP version handling:

  • examples/request_with_version.rs: Replaced println!("{:?}", resp.version()); with assert_eq!(resp.version(), Version::HTTP_11); to ensure the response version is HTTP/1.1.
  • src/util/client/mod.rs: Added is_h2 method to check if the ALPN protocol is HTTP/2, and updated the request method to handle ALPN protocols correctly. [1] [2] [3] [4]

Testing improvements:

  • tests/client.rs: Added new tests default_http_version, http1_version, and http2_version to validate the handling of different HTTP versions.
  • tests/client.rs: Removed the outdated http2_upgrade test that required TLS support in the test server.

Code cleanup:

close: #392

@0x676e67 0x676e67 merged commit dd14d49 into main Feb 5, 2025
3 checks passed
@0x676e67 0x676e67 deleted the fix branch February 5, 2025 16:36
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.

Fix upstream hyper-util does not support HTTP version negotiation request under non-tls request
1 participant