diff options
| author | Cory Benfield <lukasaoz@gmail.com> | 2012-08-10 14:47:13 +0100 |
|---|---|---|
| committer | Cory Benfield <lukasaoz@gmail.com> | 2012-08-10 14:47:13 +0100 |
| commit | 7a9419ce356d0be0383ec83b14e66658ea7f96be (patch) | |
| tree | 7139f5d55f0d16888913ff2910892291d2c0c312 /docs/user/quickstart.rst | |
| parent | 40ba6b4ec13e599ede207ec6987c37b0c1b54152 (diff) | |
| download | python-requests-7a9419ce356d0be0383ec83b14e66658ea7f96be.tar.gz | |
Document encodings and RFC compliance.
Diffstat (limited to 'docs/user/quickstart.rst')
| -rw-r--r-- | docs/user/quickstart.rst | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 9b0399d4..71ffea05 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -86,12 +86,22 @@ again:: Requests will automatically decode content from the server. Most unicode charsets are seamlessly decoded. -When you make a request, ``r.encoding`` is set, based on the HTTP headers. -Requests will use that encoding when you access ``r.text``. If ``r.encoding`` -is ``None``, Requests will make an extremely educated guess of the encoding -of the response body. You can manually set ``r.encoding`` to any encoding -you'd like, and that charset will be used. - +When you make a request, Requests makes educated guesses about the encoding of +the response based on the HTTP headers. The text encoding guessed by Requests +is used when you access ``r.text``. You can find out what encoding Requests is +using, and change it, using the ``r.encoding`` property:: + + >>> r.encoding + 'utf-8' + >>> r.encoding = 'ISO-8859-1' + +If you change the encoding, Requests will use the new value of ``r.encoding`` +whenever you call ``r.text``. + +Requests will also use custom encodings in the event that you need them. If +you have created your own encoding and registered it with the ``codecs`` +module, you can simply use the codec name as the value of ``r.encoding`` and +Requests will handle the decoding for you. Binary Response Content ----------------------- |
