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

Unicode headers name + SSL + big bodies #24

Open
lasote opened this issue Sep 13, 2016 · 5 comments
Open

Unicode headers name + SSL + big bodies #24

lasote opened this issue Sep 13, 2016 · 5 comments

Comments

@lasote
Copy link

lasote commented Sep 13, 2016

When a body is very big, using SSL, the unicode header names filled by aws4auth makes the requests crash:

OpenSSL.SSL.Error: [('SSL routines', 'SSL3_WRITE_PENDING', 'bad write retry')]

More info: https://www.bountysource.com/issues/27417596-ssl3_write_pending-error-from-urllib3-contrib-pyopenssl-sendall

I've solved making a wrapper that converts to str the header names:

    class AWS4AuthNotUnicode(AWS4Auth):
        def __call__(self, req):
            req = super(AWS4AuthNotUnicode, self).__call__(req)
            req.headers = {str(name): value for name, value in req.headers.items()}
            return req
@jamshid
Copy link

jamshid commented Feb 16, 2017

Interesting -- I wonder if #29 is related to this. Does removing this line from /usr/lib/python2.7/site-packages/requests_aws4auth/aws4auth.py also workaround the error you see with SSL?

from __future__ import unicode_literals

@jminuscula
Copy link

@jamshid after much debugging with the help from folks over at urllib3, the unicode headers are definitely the issue.

Commenting out the unicode_literals import fixed the problem for me. From the discussion on
urllib3/urllib3#855 (comment) I take that headers should not be provided as unicode strings.

Hope this helps.

@DavidLemayian
Copy link

@lasote Thank you! Solved with your workaround.

@cristianocca
Copy link

cristianocca commented Sep 15, 2017

How to work around this without patching the library?

EDIT: Monkey patch on the first post solves the issue.

@baragona
Copy link

The AWS4AuthNotUnicode fix worked for me. Wondering if this is also an issue on python3? (For future reference, this code was on python2.)

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

No branches or pull requests

6 participants