Skip to content

Commit

Permalink
📝 patch docs ref about requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ousret committed Nov 10, 2024
1 parent df8ce5e commit 995854c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions docs/getting_started/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Environment variables have the highest priority, followed by keyword arguments t
Using an HTTP or HTTPS proxy with PRAW
--------------------------------------

PRAW internally relies upon the requests_ package to handle HTTP requests. Requests
PRAW internally relies upon the niquests_ package to handle HTTP requests. Niquests
supports use of ``HTTP_PROXY`` and ``HTTPS_PROXY`` environment variables in order to
proxy HTTP and HTTPS requests respectively [`ref
<https://requests.readthedocs.io/en/master/user/advanced/#proxies>`_].
<https://niquests.readthedocs.io/en/latest/user/advanced.html#proxies>`_].

Given that PRAW exclusively communicates with Reddit via HTTPS, only the ``HTTPS_PROXY``
option should be required.
Expand All @@ -41,19 +41,19 @@ variable can be provided on the command line like so:
Configuring a custom requests Session
-------------------------------------

PRAW uses requests_ to handle networking. If your use-case requires custom
PRAW uses niquests_ to handle networking. If your use-case requires custom
configuration, it is possible to configure a custom Session_ instance and then use it
with PRAW.

For example, some networks use self-signed SSL certificates when connecting to HTTPS
sites. By default, this would raise an exception in requests_. To use a self-signed SSL
certificate without an exception from requests_, first export the certificate as a
sites. By default, this would raise an exception in niquests_. To use a self-signed SSL
certificate without an exception from niquests_, first export the certificate as a
``.pem`` file. Then configure PRAW like so:

.. code-block:: python
import praw
from requests import Session
from niquests import Session
session = Session()
Expand All @@ -69,11 +69,11 @@ certificate without an exception from requests_, first export the certificate as
The code above creates a custom Session_ instance and `configures it to use a custom
certificate
<https://requests.readthedocs.io/en/master/user/advanced/#ssl-cert-verification>`_, then
passes it as a parameter when creating the :class:`.Reddit` instance. Note that the
<https://niquests.readthedocs.io/en/latest/user/advanced.html#ssl-cert-verification>`_,
then passes it as a parameter when creating the :class:`.Reddit` instance. Note that the
example above uses a :ref:`password_flow` authentication type, but this method will work
for any authentication type.

.. _requests: https://requests.readthedocs.io
.. _niquests: https://niquests.readthedocs.io

.. _session: https://2.python-requests.org/en/master/api/#requests.Session
.. _session: https://niquests.readthedocs.io/en/latest/user/advanced.html
4 changes: 2 additions & 2 deletions docs/getting_started/multiple_instances.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Multiple Threads
PRAW is not thread safe.

In a nutshell, instances of :class:`.Reddit` are not thread-safe for a number of reasons
in its own code and each instance depends on an instance of ``requests.Session``, which
is not thread-safe [`ref <https://github.com/psf/requests/issues/2766>`_].
in its own code and each instance depends on an instance of ``niquests.Session``, which
is thread-safe.

In theory, having a unique :class:`.Reddit` instance for each thread, and making sure
that the instances are used in their respective threads only, will work.
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/refresh_token.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ following:

.. code-block:: python
import requests
import niquests
response = requests.get(
response = niquests.get(
"https://www.reddit.com/api/v1/scopes.json",
headers={"User-Agent": "fetch-scopes by u/bboe"},
)
Expand Down

0 comments on commit 995854c

Please sign in to comment.