tedder / requests-aws4auth

Amazon Web Services version 4 authentication for the Python Requests module
MIT License
178 stars 62 forks source link

Compute host header correctly #63

Closed phillipberndt closed 1 year ago

phillipberndt commented 1 year ago

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

phillipberndt commented 1 year ago

Reworked the code a bit to drop the needless extra comparison of port to None.

tedder commented 1 year ago

thanks- appreciate the comments as well.