Skip to content
Myr

sp

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 9f6246a · Browse files · 1 file+8 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−6 removed

  • other:+8 added−6 removed

1 file+8 added−6 removed

modified:docs/user/quickstart.rst+8 added-6 removed
37 unmodified lines
3839 >>> r.content40 '[{"repository":{"open_issues":0,"url":"https://github.com/...4142Requests does its best to decode content from the server. Most unicode charsets, ``gzip``, and ``deflate`` encodings are all seamlessly decoded.42Requests does its best to decode content from the server. Most unicode43charsets, ``gzip``, and ``deflate`` encodings are all seamlessly decoded.444546Make a POST Request47-------------------
3 unmodified lines
51 r = requests.post("http://httpbin.org/post")525354Typically, you want to send some form-encoded data — much like an HTML form.54To do this, simply pass a dictionary to the `data` argument. Your dictionary of data will automatically be form-encoded when the request is made::55To do this, simply pass a dictionary to the `data` argument. Your56dictionary of data will automatically be form-encoded when the request is made::5758 >>> payload = {'key1': 'value1', 'key2': 'value2'}59 >>> r = requests.post("http://httpbin.org/post", data=payload)60 >>> print r.content
54 unmodified lines
115 >>> r.content116 {117 "origin": "179.13.100.4",118 "files": {117 "hmm": "<censored...binary...data>"119 "report.xls": "<censored...binary...data>"120 },121 "form": {},122 "url": "http://httpbin.org/post",123 "args": {},
131 unmodified lines
255Requests will automatically perform location redirection while using impodotent methods.256257GitHub redirects all HTTP requests to HTTPS. Let's see what happens::258257 >>> r = request.get('http://github.com')259 >>> r = requests.get('http://github.com')260 >>> r.url261 'https://github.com/'262 >>> r.status_code263 200
5 unmodified lines
269270If you're using GET, HEAD, or OPTIONS, you can disable redirection271handling with the ``disable_redirects`` parameter::272271 >>> r = request.get('http://github.com')273 >>> r = requests.get('http://github.com')274 >>> r.status_code275 301276 >>> r.history277 []278279If you're using POST, PUT, PATCH, *&c*, you can also explicitly enable redirection as well::280279 >>> r = request.post('http://github.com')281 >>> r = requests.post('http://github.com')282 >>> r.url283 'https://github.com/'284 >>> r.history285 [<Response [301]>]
38 unmodified lines