tedder / requests-aws4auth

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

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

Closed billatq closed 1 year ago

billatq commented 7 years ago

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 commented 7 years ago

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 commented 4 years ago

please fix it

ffigiel commented 4 years ago

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 commented 4 years ago

@meox PRs are open.