diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2009-03-27 20:24:34 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2009-03-27 20:24:34 (GMT) |
commit | 236654b82df30b2df5edf72cd808f792cdde9d3a (patch) | |
tree | bf699a151050ff282f72d178273daf8a5b3fa1f4 /Doc | |
parent | 98eb6c283881168adbedf37bb34300c39954397a (diff) | |
download | cpython-236654b82df30b2df5edf72cd808f792cdde9d3a.zip cpython-236654b82df30b2df5edf72cd808f792cdde9d3a.tar.gz cpython-236654b82df30b2df5edf72cd808f792cdde9d3a.tar.bz2 |
Fix some string encoding issues with entity bodies in HTTP requests.
RFC 2616 says that iso-8859-1 is the default charset for HTTP entity
bodies, but we encoded strings using ascii. See
http://bugs.python.org/issue5314. Changed docs and code to use
iso-8859-1.
Also fix some brokenness with passing a file as the body instead of a
string.
Add tests to show that some of this behavior actually works.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/http.client.rst | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst index 26d919d..5fcc0f0 100644 --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -351,14 +351,22 @@ HTTPConnection Objects .. method:: HTTPConnection.request(method, url[, body[, headers]]) - This will send a request to the server using the HTTP request method *method* - and the selector *url*. If the *body* argument is present, it should be a - string of data to send after the headers are finished. Alternatively, it may - be an open file object, in which case the contents of the file is sent; this - file object should support ``fileno()`` and ``read()`` methods. The header - Content-Length is automatically set to the correct value. The *headers* - argument should be a mapping of extra HTTP headers to send with the request. - + This will send a request to the server using the HTTP request + method *method* and the selector *url*. If the *body* argument is + present, it should be string or bytes object of data to send after + the headers are finished. Strings are encoded as ISO-8859-1, the + default charset for HTTP. To use other encodings, pass a bytes + object. The Content-Length header is set to the length of the + string. + + The *body* may also be an open file object, in which case the + contents of the file is sent; this file object should support + ``fileno()`` and ``read()`` methods. The header Content-Length is + automatically set to the length of the file as reported by + stat. + + The *headers* argument should be a mapping of extra HTTP + headers to send with the request. .. method:: HTTPConnection.getresponse() |