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

Correctly include port in host header #23

Merged
merged 3 commits into from
Nov 12, 2024
Merged

Conversation

robalar
Copy link
Member

@robalar robalar commented Oct 31, 2024

The correct form of the Host header is ``:`. If no port is included, the default port for the service requested is implied (e.g., 443 for an HTTPS URL, and 80 for an HTTP URL).

reqwest's host_str() does not return a port, even if a non-default one is set, there for we need to add it.

src/reqwest_impls.rs Outdated Show resolved Hide resolved
@thomassa
Copy link
Collaborator

I think the third commit ("Remove unused export") should be squashed into "Remove use of deprecated chrono functions".

"Therefore" is just one word.

@thomassa thomassa closed this Oct 31, 2024
@thomassa
Copy link
Collaborator

Oops, closed in error. Sorry!

@thomassa thomassa reopened this Oct 31, 2024
The correct form of the Host header is ``<host>:<port>`.  If no port is
included, the default port for the service requested is implied (e.g.,
443 for an HTTPS URL, and 80 for an HTTP URL).

reqwest's `host_str()` does not return a port, even if a non-default one
is set, therefore we need to add it.
Also, remove unneeded export.
@robalar robalar force-pushed the rh/fix-reqwest-host branch from 8882365 to 30c4b66 Compare October 31, 2024 14:47
@robalar robalar requested a review from thomassa October 31, 2024 14:47
fn it_works_blocking() {
let config = SigningConfig::new_default("test_key", "abcdefgh".as_bytes());

let client = reqwest::blocking::Client::new();
Copy link
Collaborator

@thomassa thomassa Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a few minutes playing spot-the-difference to see that this line is the only difference between this test and the it_works test: I resorted to pasting the two of them into kdiff3 to display the difference.

Is it worth factoring out the duplicated code?
Something like

    #[test]
    fn it_works_blocking() {
        it_works(reqwest::blocking::Client::new())
    }

    #[test]
    fn it_works_async() {
        it_works(reqwest::Client::new())
    }

or using a parameterisation library such as test-case.

It's the same for the other pair of tests: the ones specifying a non-standard port.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are completely seperate types, and don't implement a shared trait for the builder (as far as i can tell) so I dont think its possible to construct a function that takes both as an argument?

Copy link
Collaborator

@thomassa thomassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave it to your judgement whether it's worth the time to factor out the duplication in the test cases.

Otherwise, all good.

@robalar robalar merged commit 1dcac5f into master Nov 12, 2024
8 of 10 checks passed
@robalar robalar deleted the rh/fix-reqwest-host branch November 12, 2024 09:11
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.

2 participants