python requests on Google App Engine not working for HTTPS

前端 未结 2 1511
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 21:28

I\'m using python-request on Google App Engine and it\'s not working as expected for HTTPS. Let\'s see an example:

import requests
requests.get(\'https://www         


        
相关标签:
2条回答
  • 2020-12-15 21:50

    Downgrading to requests==2.1.0 worked for me.

    Having an up-to-date urllib3 is important for resolving an unrelated bug (import pwd, as I recall).

    Hopefully App Engine fixes this soon, as requests won't.

    EDIT:

    I think you can also patch this in the latest requests by commenting lines 161-175 in sessions.py. Untested.

    0 讨论(0)
  • 2020-12-15 22:07

    There is now a better solution than changing your requests version. As suggested in the official docs you can monkey patch requests to play nicely with Google App Engine.

    First install requests-toolbelt:

    pip install -t lib requests-toolbelt
    

    Then in your main.py file (or equivalent):

    import requests_toolbelt.adapters.appengine
    
    requests_toolbelt.adapters.appengine.monkeypatch()
    
    0 讨论(0)
提交回复
热议问题