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

Port numbers are required if the port number is not 80/443 #34

Closed
billatq opened this issue Jul 24, 2017 · 4 comments · Fixed by #63
Closed

Port numbers are required if the port number is not 80/443 #34

billatq opened this issue Jul 24, 2017 · 4 comments · Fixed by #63

Comments

@billatq
Copy link

billatq commented Jul 24, 2017

This doesn't work correctly:

headers['host'] = urlparse(req.url).netloc.split(':')[0]

It should check to see if the port number is either 80 or 443 and include it if not.

@billatq
Copy link
Author

billatq commented Jul 24, 2017

Looks like this is an easy fix:

        if 'host' not in headers:
            host, port = urlparse(req.url).netloc.split(':')
            if (port == '80' or port == '443'):
                headers['host'] = host
            else:
                headers['host'] = host + ":" + port

@meox
Copy link

meox commented Sep 25, 2020

please fix it

@ffigiel
Copy link

ffigiel commented Sep 26, 2020

this can be solved on the client side by specifying the host header

         self.sess = requests.Session()
         self.sess.auth = AWS4Auth(access_key, secret_key, '', 'rramp')
+        self.sess.headers['host'] = urlparse(self.host).netloc

@tedder
Copy link
Owner

tedder commented Sep 29, 2020

@meox PRs are open.

phillipberndt added a commit to phillipberndt/requests-aws4auth that referenced this issue Jan 19, 2023
Signatures need to include the host header, but the requests library
does not include it in prepared requests by default. Rather, it trusts
that Python's HTTP client will compute and inject it when sending the
request. This forces requests-aws4auth to compute how this header will
look like.

A slight discrepancy between the implementations is that the code in
this library unconditionally skips the port, whereas the request ending
up being sent will include a port if it does not match the URL scheme's
default.

This change adjusts the implementations to match in that regard.

Fixes tedder#34
phillipberndt added a commit to phillipberndt/requests-aws4auth that referenced this issue Jan 19, 2023
Signatures need to include the host header, but the requests library
does not include it in prepared requests by default. Rather, it trusts
that Python's HTTP client will compute and inject it when sending the
request. This forces requests-aws4auth to compute how this header will
look like.

A slight discrepancy between the implementations is that the code in
this library unconditionally skips the port, whereas the request ending
up being sent will include a port if it does not match the URL scheme's
default.

This change adjusts the implementations to match in that regard.

Fixes tedder#34
phillipberndt added a commit to phillipberndt/requests-aws4auth that referenced this issue Jan 20, 2023
Signatures need to include the host header, but the requests library
does not include it in prepared requests by default. Rather, it trusts
that Python's HTTP client will compute and inject it when sending the
request. This forces requests-aws4auth to compute how this header will
look like.

A slight discrepancy between the implementations is that the code in
this library unconditionally skips the port, whereas the request ending
up being sent will include a port if it does not match the URL scheme's
default.

This change adjusts the implementations to match in that regard.

Fixes tedder#34
phillipberndt added a commit to phillipberndt/requests-aws4auth that referenced this issue Jan 20, 2023
Signatures need to include the host header, but the requests library
does not include it in prepared requests by default. Rather, it trusts
that Python's HTTP client will compute and inject it when sending the
request. This forces requests-aws4auth to compute how this header will
look like.

A slight discrepancy between the implementations is that the code in
this library unconditionally skips the port, whereas the request ending
up being sent will include a port if it does not match the URL scheme's
default.

This change adjusts the implementations to match in that regard.

Fixes tedder#34
tedder pushed a commit that referenced this issue Jan 20, 2023
Signatures need to include the host header, but the requests library
does not include it in prepared requests by default. Rather, it trusts
that Python's HTTP client will compute and inject it when sending the
request. This forces requests-aws4auth to compute how this header will
look like.

A slight discrepancy between the implementations is that the code in
this library unconditionally skips the port, whereas the request ending
up being sent will include a port if it does not match the URL scheme's
default.

This change adjusts the implementations to match in that regard.

Fixes #34
tedder added a commit that referenced this issue Jan 20, 2023
tedder added a commit that referenced this issue Feb 3, 2023
This reverts commit 8e1417c.

Fixing #34 and #63 caused a regression bug.
phillipberndt added a commit to phillipberndt/requests-aws4auth that referenced this issue May 15, 2023
See tedder#65 and tedder#34. This adds a failing test that would be fixed by 8e1417.
phillipberndt added a commit to phillipberndt/requests-aws4auth that referenced this issue May 15, 2023
See tedder#65 and tedder#34. This adds a failing test that would be fixed by 8e1417.
tedder pushed a commit that referenced this issue May 15, 2023
See #65 and #34. This adds a failing test that would be fixed by 8e1417.
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 a pull request may close this issue.

4 participants