fix: Ensure HTTP version negotiation for non-TLS requests #397
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.
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
: Replacedprintln!("{:?}", resp.version());
withassert_eq!(resp.version(), Version::HTTP_11);
to ensure the response version is HTTP/1.1.src/util/client/mod.rs
: Addedis_h2
method to check if the ALPN protocol is HTTP/2, and updated therequest
method to handle ALPN protocols correctly. [1] [2] [3] [4]Testing improvements:
tests/client.rs
: Added new testsdefault_http_version
,http1_version
, andhttp2_version
to validate the handling of different HTTP versions.tests/client.rs
: Removed the outdatedhttp2_upgrade
test that required TLS support in the test server.Code cleanup:
tests/client.rs
: Updated imports to includeVersion
from thehttp
crate.close: #392