Skip to content
Myr

faq.rst

This file

Path

docs/community/faq.rst

88 lines · 3.3 KiB

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 3cf4ec4 point at it.

Merge pull request #2729 from smiley/patch-1Cory Benfieldbefore adoption3cf4ec4

lines 1–88why, one step back
1.. _faq:
23Frequently Asked Questions4==========================56This part of the documentation answers common questions about Requests.78Encoded Data?9-------------1011Requests automatically decompresses gzip-encoded responses, and does12its best to decode response content to unicode when possible.1314You can get direct access to the raw response (and even the socket),15if needed as well.161718Custom User-Agents?19-------------------2021Requests allows you to easily override User-Agent strings, along with22any other HTTP Header.232425Why not Httplib2?26-----------------2728Chris Adams gave an excellent summary on29`Hacker News <http://news.ycombinator.com/item?id=2884406>`_:3031 httplib2 is part of why you should use requests: it's far more respectable32 as a client but not as well documented and it still takes way too much code33 for basic operations. I appreciate what httplib2 is trying to do, that34 there's a ton of hard low-level annoyances in building a modern HTTP35 client, but really, just use requests instead. Kenneth Reitz is very36 motivated and he gets the degree to which simple things should be simple37 whereas httplib2 feels more like an academic exercise than something38 people should use to build production systems[1].3940 Disclosure: I'm listed in the requests AUTHORS file but can claim credit41 for, oh, about 0.0001% of the awesomeness.4243 1. http://code.google.com/p/httplib2/issues/detail?id=96 is a good example:44 an annoying bug which affect many people, there was a fix available for45 months, which worked great when I applied it in a fork and pounded a couple46 TB of data through it, but it took over a year to make it into trunk and47 even longer to make it onto PyPI where any other project which required "48 httplib2" would get the working version.495051Python 3 Support?52-----------------5354Yes! Here's a list of Python platforms that are officially55supported:5657* Python 2.658* Python 2.759* Python 3.160* Python 3.261* Python 3.362* Python 3.463* PyPy 1.964* PyPy 2.26566What are "hostname doesn't match" errors?67-----------------------------------------6869These errors occur when :ref:`SSL certificate verification <verification>`70fails to match the certificate the server responds with to the hostname71Requests thinks it's contacting. If you're certain the server's SSL setup is72correct (for example, because you can visit the site with your browser) and73you're using Python 2.6 or 2.7, a possible explanation is that you need74Server-Name-Indication.7576`Server-Name-Indication`_, or SNI, is an official extension to SSL where the77client tells the server what hostname it is contacting. This is important78when servers are using `Virtual Hosting`_. When such servers are hosting79more than one SSL site they need to be able to return the appropriate80certificate based on the hostname the client is connecting to.8182Python3 and Python 2.7.9+ include native support for SNI in their SSL modules.83For information on using SNI with Requests on Python < 2.7.9 refer to this84`Stack Overflow answer`_.8586.. _`Server-Name-Indication`: https://en.wikipedia.org/wiki/Server_Name_Indication87.. _`virtual hosting`: https://en.wikipedia.org/wiki/Virtual_hosting88.. _`Stack Overflow answer`: https://stackoverflow.com/questions/18578439/using-requests-with-tls-doesnt-give-sni-support/18579484#18579484