-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into idle_timeout
- Loading branch information
Showing
50 changed files
with
745 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Allowed passing negative integers as ``amt`` to read methods of | ||
:class:`http.client.HTTPResponse` as an alternative to ``None``. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Updated docs for ``.json()`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
h2==4.1.0 | ||
coverage==7.4.0 | ||
coverage==7.4.1 | ||
PySocks==1.7.1 | ||
pytest==7.4.2 | ||
pytest==7.4.4 | ||
pytest-timeout==2.1.0 | ||
pyOpenSSL==23.2.0 | ||
pyOpenSSL==24.0.0 | ||
idna==3.4 | ||
trustme==1.1.0 | ||
cryptography==41.0.6 | ||
cryptography==42.0.4 | ||
backports.zoneinfo==0.2.1;python_version<"3.9" | ||
towncrier==23.6.0 | ||
pytest-memray==1.5.0;sys_platform!="win32" and implementation_name=="cpython" | ||
trio==0.23.1 | ||
pytest-memray==1.5.0;python_version<"3.13" and sys_platform!="win32" and implementation_name=="cpython" | ||
trio==0.23.1;python_version<"3.13" | ||
# We need a release of Trio newer than 0.24.0 to support CPython 3.13. | ||
# https://github.com/python-trio/trio/issues/2903 | ||
trio @ git+https://github.com/python-trio/trio@e4c8eb2d7ef59eeea1441656e392fe1b0870a374; python_version == "3.13" | ||
Quart==0.19.4 | ||
quart-trio==0.11.1 | ||
# https://github.com/pgjones/hypercorn/issues/62 | ||
# https://github.com/pgjones/hypercorn/issues/168 | ||
# https://github.com/pgjones/hypercorn/issues/169 | ||
hypercorn @ git+https://github.com/urllib3/hypercorn@urllib3-changes | ||
httpx==0.25.2 | ||
pytest-socket==0.7.0 | ||
# CFFI is not going to support CPython 3.13 in an actual release until | ||
# there is a release candidate for 3.13. | ||
# https://github.com/python-cffi/cffi/issues/23#issuecomment-1845861410 | ||
cffi @ git+https://github.com/python-cffi/cffi@14723b0bbd127790c450945099db31018d80fa83; python_version == "3.13" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
Pyodide, Emscripten, and PyScript | ||
================================= | ||
|
||
From the Pyodide documentation, `Pyodide <https://pyodide.org>`_ is a Python distribution for the browser and Node.js based on WebAssembly and `Emscripten <https://emscripten.org/>`_. | ||
This technology also underpins the `PyScript framework <https://pyscript.net/>`_ and `Jupyterlite <https://jupyterlite.readthedocs.io/>`_, so should work in those environments too. | ||
|
||
Starting in version 2.2.0 urllib3 supports being used in a Pyodide runtime utilizing | ||
the `JavaScript fetch API <https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API>`_ | ||
or falling back on `XMLHttpRequest <https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest>`_ | ||
if the fetch API isn't available (such as when cross-origin isolation | ||
isn't active). This means you can use Python libraries to make HTTP requests from your browser! | ||
|
||
Because urllib3's Emscripten support is API-compatible, this means that | ||
libraries that depend on urllib3 may now be usable from Emscripten and Pyodide environments, too. | ||
|
||
.. warning:: | ||
|
||
**Support for Emscripten and Pyodide is experimental**. Report all bugs to the `urllib3 issue tracker <https://github.com/urllib3/urllib3/issues>`_. | ||
Currently only supports browsers, does not yet support running in Node.js. | ||
|
||
It's recommended to `run Pyodide in a Web Worker <https://pyodide.org/en/stable/usage/webworker.html#using-from-webworker>`_ | ||
in order to take full advantage of features like the fetch API which enables streaming of HTTP response bodies. | ||
|
||
Getting started | ||
--------------- | ||
|
||
Using urllib3 with Pyodide means you need to `get started with Pyodide first <https://pyodide.org/en/stable/usage/quickstart.html>`_. | ||
The Pyodide project provides a `useful online REPL <https://pyodide.org/en/stable/console.html>`_ to try in your browser without | ||
any setup or installation to test out the code examples below. | ||
|
||
urllib3's Emscripten support is automatically enabled if ``sys.platform`` is ``"emscripten"``, so no setup is required beyond installation and importing the module. | ||
|
||
You can install urllib3 in a Pyodide environment using micropip. | ||
Try using the following code in a Pyodide console or ``<script>`` tag: | ||
|
||
.. code-block:: python | ||
import micropip | ||
await micropip.install("urllib3") | ||
import urllib3 | ||
resp = urllib3.request("GET", "https://httpbin.org/anything") | ||
print(resp.status) # 200 | ||
print(resp.headers) # HTTPHeaderDict(...) | ||
print(resp.json()) # {"headers": {"Accept": "*/*", ...}, ...} | ||
Because `Requests <https://requests.readthedocs.io/en/latest/>`_ is built on urllib3, Requests also works out of the box: | ||
|
||
.. code-block:: python | ||
import micropip | ||
await micropip.install("requests") | ||
import requests | ||
resp = requests.request("GET", "https://httpbin.org/anything") | ||
print(resp.status_code) # 200 | ||
print(resp.headers) | ||
Features | ||
-------- | ||
|
||
Because we use JavaScript APIs under the hood, it's not possible to use all of urllib3 features. | ||
Features which are usable with Emscripten support are: | ||
|
||
* Requests over HTTP and HTTPS | ||
* Timeouts | ||
* Retries | ||
* Streaming (with Web Workers and Cross-Origin Isolation) | ||
* Redirects | ||
* Decompressing response bodies | ||
|
||
Features which don't work with Emscripten: | ||
|
||
* Proxies, both forwarding and tunneling | ||
* Customizing TLS and certificates (uses browsers' configuration) | ||
* Configuring low-level socket options or source address | ||
|
||
Streaming with Web Workers | ||
-------------------------- | ||
|
||
To access the fetch API and do HTTP response streaming with urllib3 | ||
you must be running the code within a Web Worker and set specific HTTP headers | ||
for the serving website to enable `Cross-Origin Isolation <https://developer.mozilla.org/en-US/docs/Web/API/crossOriginIsolated>`_. | ||
|
||
You can verify whether a given environment is cross-origin isolated by evaluating the global ``crossOriginIsolated`` JavaScript property. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ prime time or that require optional third-party dependencies. | |
|
||
.. toctree:: | ||
|
||
emscripten | ||
pyopenssl | ||
socks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.