| OLD | NEW |
| (Empty) |
| 1 .. _faq: | |
| 2 | |
| 3 Frequently Asked Questions | |
| 4 ========================== | |
| 5 | |
| 6 This part of the documentation answers common questions about Requests. | |
| 7 | |
| 8 Encoded Data? | |
| 9 ------------- | |
| 10 | |
| 11 Requests automatically decompresses gzip-encoded responses, and does | |
| 12 its best to decode response content to unicode when possible. | |
| 13 | |
| 14 You can get direct access to the raw response (and even the socket), | |
| 15 if needed as well. | |
| 16 | |
| 17 | |
| 18 Custom User-Agents? | |
| 19 ------------------- | |
| 20 | |
| 21 Requests allows you to easily override User-Agent strings, along with | |
| 22 any other HTTP Header. | |
| 23 | |
| 24 | |
| 25 Why not Httplib2? | |
| 26 ----------------- | |
| 27 | |
| 28 Chris Adams gave an excellent summary on | |
| 29 `Hacker News <http://news.ycombinator.com/item?id=2884406>`_: | |
| 30 | |
| 31 httplib2 is part of why you should use requests: it's far more respectable | |
| 32 as a client but not as well documented and it still takes way too much code | |
| 33 for basic operations. I appreciate what httplib2 is trying to do, that | |
| 34 there's a ton of hard low-level annoyances in building a modern HTTP | |
| 35 client, but really, just use requests instead. Kenneth Reitz is very | |
| 36 motivated and he gets the degree to which simple things should be simple | |
| 37 whereas httplib2 feels more like an academic exercise than something | |
| 38 people should use to build production systems[1]. | |
| 39 | |
| 40 Disclosure: I'm listed in the requests AUTHORS file but can claim credit | |
| 41 for, oh, about 0.0001% of the awesomeness. | |
| 42 | |
| 43 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 for | |
| 45 months, which worked great when I applied it in a fork and pounded a couple | |
| 46 TB of data through it, but it took over a year to make it into trunk and | |
| 47 even longer to make it onto PyPI where any other project which required " | |
| 48 httplib2" would get the working version. | |
| 49 | |
| 50 | |
| 51 Python 3 Support? | |
| 52 ----------------- | |
| 53 | |
| 54 Yes! Here's a list of Python platforms that are officially | |
| 55 supported: | |
| 56 | |
| 57 * Python 2.6 | |
| 58 * Python 2.7 | |
| 59 * Python 3.1 | |
| 60 * Python 3.2 | |
| 61 * Python 3.3 | |
| 62 * Python 3.4 | |
| 63 * PyPy 1.9 | |
| 64 * PyPy 2.2 | |
| 65 | |
| 66 What are "hostname doesn't match" errors? | |
| 67 ----------------------------------------- | |
| 68 | |
| 69 These errors occur when :ref:`SSL certificate verification <verification>` | |
| 70 fails to match the certificate the server responds with to the hostname | |
| 71 Requests thinks it's contacting. If you're certain the server's SSL setup is | |
| 72 correct (for example, because you can visit the site with your browser) and | |
| 73 you're using Python 2.6 or 2.7, a possible explanation is that you need | |
| 74 Server-Name-Indication. | |
| 75 | |
| 76 `Server-Name-Indication`_, or SNI, is an official extension to SSL where the | |
| 77 client tells the server what hostname it is contacting. This is important | |
| 78 when servers are using `Virtual Hosting`_. When such servers are hosting | |
| 79 more than one SSL site they need to be able to return the appropriate | |
| 80 certificate based on the hostname the client is connecting to. | |
| 81 | |
| 82 Python3 and Python 2.7.9+ include native support for SNI in their SSL modules. | |
| 83 For information on using SNI with Requests on Python < 2.7.9 refer to this | |
| 84 `Stack Overflow answer`_. | |
| 85 | |
| 86 .. _`Server-Name-Indication`: https://en.wikipedia.org/wiki/Server_Name_Indicati
on | |
| 87 .. _`virtual hosting`: https://en.wikipedia.org/wiki/Virtual_hosting | |
| 88 .. _`Stack Overflow answer`: https://stackoverflow.com/questions/18578439/using-
requests-with-tls-doesnt-give-sni-support/18579484#18579484 | |
| OLD | NEW |