summaryrefslogtreecommitdiff
path: root/docs/user
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2018-09-30 17:14:40 -0500
committerJon Dufresne <jon.dufresne@gmail.com>2018-09-30 17:14:40 -0500
commitb0ad2499c8641d29affc90f565e6628d333d2a96 (patch)
treebe0efafc79d1c7962125264b63afd813aff5ad45 /docs/user
parent8f20b7dc8f79046d0a1015b9605df5c30fa44197 (diff)
downloadpython-requests-b0ad2499c8641d29affc90f565e6628d333d2a96.tar.gz
Prefer https:// for URLs throughout project
Diffstat (limited to 'docs/user')
-rw-r--r--docs/user/advanced.rst42
-rw-r--r--docs/user/authentication.rst6
-rw-r--r--docs/user/install.rst2
-rw-r--r--docs/user/intro.rst4
-rw-r--r--docs/user/quickstart.rst50
5 files changed, 52 insertions, 52 deletions
diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst
index 2076fc00..9a615aae 100644
--- a/docs/user/advanced.rst
+++ b/docs/user/advanced.rst
@@ -25,8 +25,8 @@ Let's persist some cookies across requests::
s = requests.Session()
- s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')
- r = s.get('http://httpbin.org/cookies')
+ s.get('https://httpbin.org/cookies/set/sessioncookie/123456789')
+ r = s.get('https://httpbin.org/cookies')
print(r.text)
# '{"cookies": {"sessioncookie": "123456789"}}'
@@ -40,7 +40,7 @@ is done by providing data to the properties on a Session object::
s.headers.update({'x-test': 'true'})
# both 'x-test' and 'x-test2' are sent
- s.get('http://httpbin.org/headers', headers={'x-test2': 'true'})
+ s.get('https://httpbin.org/headers', headers={'x-test2': 'true'})
Any dictionaries that you pass to a request method will be merged with the
@@ -53,11 +53,11 @@ with the first request, but not the second::
s = requests.Session()
- r = s.get('http://httpbin.org/cookies', cookies={'from-my': 'browser'})
+ r = s.get('https://httpbin.org/cookies', cookies={'from-my': 'browser'})
print(r.text)
# '{"cookies": {"from-my": "browser"}}'
- r = s.get('http://httpbin.org/cookies')
+ r = s.get('https://httpbin.org/cookies')
print(r.text)
# '{"cookies": {}}'
@@ -69,7 +69,7 @@ If you want to manually add cookies to your session, use the
Sessions can also be used as context managers::
with requests.Session() as s:
- s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')
+ s.get('https://httpbin.org/cookies/set/sessioncookie/123456789')
This will make sure the session is closed as soon as the ``with`` block is
exited, even if unhandled exceptions occurred.
@@ -97,7 +97,7 @@ The ``Response`` object contains all of the information returned by the server a
also contains the ``Request`` object you created originally. Here is a simple
request to get some very important information from Wikipedia's servers::
- >>> r = requests.get('http://en.wikipedia.org/wiki/Monty_Python')
+ >>> r = requests.get('https://en.wikipedia.org/wiki/Monty_Python')
If we want to access the headers the server sent back to us, we do this::
@@ -323,7 +323,7 @@ inefficiency with connections. If you find yourself partially reading request
bodies (or not reading them at all) while using ``stream=True``, you should
make the request within a ``with`` statement to ensure it's always closed::
- with requests.get('http://httpbin.org/get', stream=True) as r:
+ with requests.get('https://httpbin.org/get', stream=True) as r:
# Do things with the response here.
.. _keep-alive:
@@ -393,7 +393,7 @@ upload image files to an HTML form with a multiple file field 'images'::
To do that, just set files to a list of tuples of ``(form_field_name, file_info)``::
- >>> url = 'http://httpbin.org/post'
+ >>> url = 'https://httpbin.org/post'
>>> multiple_files = [
('images', ('foo.png', open('foo.png', 'rb'), 'image/png')),
('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]
@@ -455,13 +455,13 @@ anything, nothing else is affected.
Let's print some request method arguments at runtime::
- >>> requests.get('http://httpbin.org', hooks={'response': print_url})
- http://httpbin.org
+ >>> requests.get('https://httpbin.org/', hooks={'response': print_url})
+ https://httpbin.org/
<Response [200]>
You can add multiple hooks to a single request. Let's call two hooks at once::
- >>> r = requests.get('http://httpbin.org', hooks={'response': [print_url, record_hook]})
+ >>> r = requests.get('https://httpbin.org/', hooks={'response': [print_url, record_hook]})
>>> r.hook_called
True
@@ -470,8 +470,8 @@ be called on every request made to the session. For example::
>>> s = requests.Session()
>>> s.hooks['response'].append(print_url)
- >>> s.get('http://httpbin.org')
- http://httpbin.org
+ >>> s.get('https://httpbin.org/')
+ https://httpbin.org/
<Response [200]>
A ``Session`` can have multiple hooks, which will be called in the order
@@ -529,7 +529,7 @@ set ``stream`` to ``True`` and iterate over the response with
import json
import requests
- r = requests.get('http://httpbin.org/stream/20', stream=True)
+ r = requests.get('https://httpbin.org/stream/20', stream=True)
for line in r.iter_lines():
@@ -543,7 +543,7 @@ When using `decode_unicode=True` with
:meth:`Response.iter_content() <requests.Response.iter_content>`, you'll want
to provide a fallback encoding in the event the server doesn't provide one::
- r = requests.get('http://httpbin.org/stream/20', stream=True)
+ r = requests.get('https://httpbin.org/stream/20', stream=True)
if r.encoding is None:
r.encoding = 'utf-8'
@@ -657,7 +657,7 @@ encoding in the HTTP header, and if none is present, will use `chardet
The only time Requests will not do this is if no explicit charset
is present in the HTTP headers **and** the ``Content-Type``
header contains ``text``. In this situation, `RFC 2616
-<http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1>`_ specifies
+<https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1>`_ specifies
that the default charset must be ``ISO-8859-1``. Requests follows the
specification in this case. If you require a different encoding, you can
manually set the :attr:`Response.encoding <requests.Response.encoding>`
@@ -921,7 +921,7 @@ it should apply to.
::
>>> s = requests.Session()
- >>> s.mount('http://www.github.com', MyAdapter())
+ >>> s.mount('https://github.com/', MyAdapter())
The mount call registers a specific instance of a Transport Adapter to a
prefix. Once mounted, any HTTP request made using that session whose URL starts
@@ -959,7 +959,7 @@ library to use SSLv3::
num_pools=connections, maxsize=maxsize,
block=block, ssl_version=ssl.PROTOCOL_SSLv3)
-.. _`described here`: http://www.kennethreitz.org/essays/the-future-of-python-http
+.. _`described here`: https://www.kennethreitz.org/essays/the-future-of-python-http
.. _`urllib3`: https://github.com/shazow/urllib3
.. _blocking-or-nonblocking:
@@ -1003,7 +1003,7 @@ The **connect** timeout is the number of seconds Requests will wait for your
client to establish a connection to a remote machine (corresponding to the
`connect()`_) call on the socket. It's a good practice to set connect timeouts
to slightly larger than a multiple of 3, which is the default `TCP packet
-retransmission window <http://www.hjp.at/doc/rfc/rfc2988.txt>`_.
+retransmission window <https://www.hjp.at/doc/rfc/rfc2988.txt>`_.
Once your client has connected to the server and sent the HTTP request, the
**read** timeout is the number of seconds the client will wait for the server
@@ -1028,4 +1028,4 @@ coffee.
r = requests.get('https://github.com', timeout=None)
-.. _`connect()`: http://linux.die.net/man/2/connect
+.. _`connect()`: https://linux.die.net/man/2/connect
diff --git a/docs/user/authentication.rst b/docs/user/authentication.rst
index 411f79fd..bff80986 100644
--- a/docs/user/authentication.rst
+++ b/docs/user/authentication.rst
@@ -53,7 +53,7 @@ Another very popular form of HTTP Authentication is Digest Authentication,
and Requests supports this out of the box as well::
>>> from requests.auth import HTTPDigestAuth
- >>> url = 'http://httpbin.org/digest-auth/auth/user/pass'
+ >>> url = 'https://httpbin.org/digest-auth/auth/user/pass'
>>> requests.get(url, auth=HTTPDigestAuth('user', 'pass'))
<Response [200]>
@@ -122,7 +122,7 @@ To do so, subclass :class:`AuthBase <requests.auth.AuthBase>` and implement the
... # Implement my authentication
... return r
...
- >>> url = 'http://httpbin.org/get'
+ >>> url = 'https://httpbin.org/get'
>>> requests.get(url, auth=MyAuth())
<Response [200]>
@@ -134,7 +134,7 @@ authentication will additionally add hooks to provide further functionality.
Further examples can be found under the `Requests organization`_ and in the
``auth.py`` file.
-.. _OAuth: http://oauth.net/
+.. _OAuth: https://oauth.net/
.. _requests_oauthlib: https://github.com/requests/requests-oauthlib
.. _requests-oauthlib OAuth2 documentation: https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html
.. _Web Application Flow: https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#web-application-flow
diff --git a/docs/user/install.rst b/docs/user/install.rst
index 1dd9de8e..3888876a 100644
--- a/docs/user/install.rst
+++ b/docs/user/install.rst
@@ -18,7 +18,7 @@ To install Requests, simply run this simple command in your terminal of choice::
$ pipenv install requests
If you don't have `pipenv <http://pipenv.org/>`_ installed (tisk tisk!), head over to the Pipenv website for installation instructions. Or, if you prefer to just use pip and don't have it installed,
-`this Python installation guide <http://docs.python-guide.org/en/latest/starting/installation/>`_
+`this Python installation guide <https://docs.python-guide.org/starting/installation/>`_
can guide you through the process.
Get the Source Code
diff --git a/docs/user/intro.rst b/docs/user/intro.rst
index e8395d9d..be9dfaa8 100644
--- a/docs/user/intro.rst
+++ b/docs/user/intro.rst
@@ -37,8 +37,8 @@ closed-source software.
Requests is released under terms of `Apache2 License`_.
-.. _`GPL Licensed`: http://www.opensource.org/licenses/gpl-license.php
-.. _`Apache2 License`: http://opensource.org/licenses/Apache-2.0
+.. _`GPL Licensed`: https://opensource.org/licenses/gpl-license.php
+.. _`Apache2 License`: https://opensource.org/licenses/Apache-2.0
Requests License
diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst
index 699c0ffd..1a75b5ce 100644
--- a/docs/user/quickstart.rst
+++ b/docs/user/quickstart.rst
@@ -39,15 +39,15 @@ get all the information we need from this object.
Requests' simple API means that all forms of HTTP request are as obvious. For
example, this is how you make an HTTP POST request::
- >>> r = requests.post('http://httpbin.org/post', data = {'key':'value'})
+ >>> r = requests.post('https://httpbin.org/post', data = {'key':'value'})
Nice, right? What about the other HTTP request types: PUT, DELETE, HEAD and
OPTIONS? These are all just as simple::
- >>> r = requests.put('http://httpbin.org/put', data = {'key':'value'})
- >>> r = requests.delete('http://httpbin.org/delete')
- >>> r = requests.head('http://httpbin.org/get')
- >>> r = requests.options('http://httpbin.org/get')
+ >>> r = requests.put('https://httpbin.org/put', data = {'key':'value'})
+ >>> r = requests.delete('https://httpbin.org/delete')
+ >>> r = requests.head('https://httpbin.org/get')
+ >>> r = requests.options('https://httpbin.org/get')
That's all well and good, but it's also only the start of what Requests can
do.
@@ -65,12 +65,12 @@ using the ``params`` keyword argument. As an example, if you wanted to pass
following code::
>>> payload = {'key1': 'value1', 'key2': 'value2'}
- >>> r = requests.get('http://httpbin.org/get', params=payload)
+ >>> r = requests.get('https://httpbin.org/get', params=payload)
You can see that the URL has been correctly encoded by printing the URL::
>>> print(r.url)
- http://httpbin.org/get?key2=value2&key1=value1
+ https://httpbin.org/get?key2=value2&key1=value1
Note that any dictionary key whose value is ``None`` will not be added to the
URL's query string.
@@ -79,9 +79,9 @@ You can also pass a list of items as a value::
>>> payload = {'key1': 'value1', 'key2': ['value2', 'value3']}
- >>> r = requests.get('http://httpbin.org/get', params=payload)
+ >>> r = requests.get('https://httpbin.org/get', params=payload)
>>> print(r.url)
- http://httpbin.org/get?key1=value1&key2=value2&key2=value3
+ https://httpbin.org/get?key1=value1&key2=value2&key2=value3
Response Content
----------------
@@ -233,7 +233,7 @@ dictionary of data will automatically be form-encoded when the request is made::
>>> payload = {'key1': 'value1', 'key2': 'value2'}
- >>> r = requests.post("http://httpbin.org/post", data=payload)
+ >>> r = requests.post("https://httpbin.org/post", data=payload)
>>> print(r.text)
{
...
@@ -250,9 +250,9 @@ as values. This is particularly useful when the form has multiple elements that
use the same key::
>>> payload_tuples = [('key1', 'value1'), ('key1', 'value2')]
- >>> r1 = requests.post('http://httpbin.org/post', data=payload_tuples)
+ >>> r1 = requests.post('https://httpbin.org/post', data=payload_tuples)
>>> payload_dict = {'key1': ['value1', 'value2']}
- >>> r2 = requests.post('http://httpbin.org/post', data=payload_dict)
+ >>> r2 = requests.post('https://httpbin.org/post', data=payload_dict)
>>> print(r1.text)
{
...
@@ -296,7 +296,7 @@ POST a Multipart-Encoded File
Requests makes it simple to upload Multipart-encoded files::
- >>> url = 'http://httpbin.org/post'
+ >>> url = 'https://httpbin.org/post'
>>> files = {'file': open('report.xls', 'rb')}
>>> r = requests.post(url, files=files)
@@ -311,7 +311,7 @@ Requests makes it simple to upload Multipart-encoded files::
You can set the filename, content_type and headers explicitly::
- >>> url = 'http://httpbin.org/post'
+ >>> url = 'https://httpbin.org/post'
>>> files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}
>>> r = requests.post(url, files=files)
@@ -326,7 +326,7 @@ You can set the filename, content_type and headers explicitly::
If you want, you can send strings to be received as files::
- >>> url = 'http://httpbin.org/post'
+ >>> url = 'https://httpbin.org/post'
>>> files = {'file': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')}
>>> r = requests.post(url, files=files)
@@ -360,7 +360,7 @@ Response Status Codes
We can check the response status code::
- >>> r = requests.get('http://httpbin.org/get')
+ >>> r = requests.get('https://httpbin.org/get')
>>> r.status_code
200
@@ -374,7 +374,7 @@ If we made a bad request (a 4XX client error or 5XX server error response), we
can raise it with
:meth:`Response.raise_for_status() <requests.Response.raise_for_status>`::
- >>> bad_r = requests.get('http://httpbin.org/status/404')
+ >>> bad_r = requests.get('https://httpbin.org/status/404')
>>> bad_r.status_code
404
@@ -410,7 +410,7 @@ We can view the server's response headers using a Python dictionary::
}
The dictionary is special, though: it's made just for HTTP headers. According to
-`RFC 7230 <http://tools.ietf.org/html/rfc7230#section-3.2>`_, HTTP Header names
+`RFC 7230 <https://tools.ietf.org/html/rfc7230#section-3.2>`_, HTTP Header names
are case-insensitive.
So, we can access the headers using any capitalization we want::
@@ -424,7 +424,7 @@ So, we can access the headers using any capitalization we want::
It is also special in that the server could have sent the same header multiple
times with different values, but requests combines them so they can be
represented in the dictionary within a single mapping, as per
-`RFC 7230 <http://tools.ietf.org/html/rfc7230#section-3.2>`_:
+`RFC 7230 <https://tools.ietf.org/html/rfc7230#section-3.2>`_:
A recipient MAY combine multiple header fields with the same field name
into one "field-name: field-value" pair, without changing the semantics
@@ -445,7 +445,7 @@ If a response contains some Cookies, you can quickly access them::
To send your own cookies to the server, you can use the ``cookies``
parameter::
- >>> url = 'http://httpbin.org/cookies'
+ >>> url = 'https://httpbin.org/cookies'
>>> cookies = dict(cookies_are='working')
>>> r = requests.get(url, cookies=cookies)
@@ -460,7 +460,7 @@ also be passed in to requests::
>>> jar = requests.cookies.RequestsCookieJar()
>>> jar.set('tasty_cookie', 'yum', domain='httpbin.org', path='/cookies')
>>> jar.set('gross_cookie', 'blech', domain='httpbin.org', path='/elsewhere')
- >>> url = 'http://httpbin.org/cookies'
+ >>> url = 'https://httpbin.org/cookies'
>>> r = requests.get(url, cookies=jar)
>>> r.text
'{"cookies": {"tasty_cookie": "yum"}}'
@@ -481,7 +481,7 @@ response.
For example, GitHub redirects all HTTP requests to HTTPS::
- >>> r = requests.get('http://github.com')
+ >>> r = requests.get('https://github.com/')
>>> r.url
'https://github.com/'
@@ -496,7 +496,7 @@ For example, GitHub redirects all HTTP requests to HTTPS::
If you're using GET, OPTIONS, POST, PUT, PATCH or DELETE, you can disable
redirection handling with the ``allow_redirects`` parameter::
- >>> r = requests.get('http://github.com', allow_redirects=False)
+ >>> r = requests.get('https://github.com/', allow_redirects=False)
>>> r.status_code
301
@@ -506,7 +506,7 @@ redirection handling with the ``allow_redirects`` parameter::
If you're using HEAD, you can enable redirection as well::
- >>> r = requests.head('http://github.com', allow_redirects=True)
+ >>> r = requests.head('https://github.com/', allow_redirects=True)
>>> r.url
'https://github.com/'
@@ -523,7 +523,7 @@ seconds with the ``timeout`` parameter. Nearly all production code should use
this parameter in nearly all requests. Failure to do so can cause your program
to hang indefinitely::
- >>> requests.get('http://github.com', timeout=0.001)
+ >>> requests.get('https://github.com/', timeout=0.001)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
requests.exceptions.Timeout: HTTPConnectionPool(host='github.com', port=80): Request timed out. (timeout=0.001)