mirror of
https://github.com/kennethreitz/requests3.git
synced 2026-06-05 23:10:16 +00:00
intend to use httpcore
This commit is contained in:
@@ -24,3 +24,4 @@ pytest-mypy = "*"
|
||||
white = {version = "*"}
|
||||
"rfc3986" = "*"
|
||||
twisted = {extras = ["tls"]}
|
||||
httpcore = {git = "https://github.com/encode/httpcore.git"}
|
||||
|
||||
Generated
+5
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "20bb79af8e1c93904021d53336ecce1a0a9e5dedcd1d79e08439bf3f4d9681f9"
|
||||
"sha256": "d16571af6a7c4058f9b33f1af783cc5f0a87de0a4c0badb2b925a19ab8996c69"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {},
|
||||
@@ -355,6 +355,10 @@
|
||||
"index": "pypi",
|
||||
"version": "==0.7.0"
|
||||
},
|
||||
"httpcore": {
|
||||
"git": "https://github.com/encode/httpcore.git",
|
||||
"ref": "23252f6cd9e629ae7c513bc24a8c6a1061d61429"
|
||||
},
|
||||
"hyperlink": {
|
||||
"hashes": [
|
||||
"sha256:4288e34705da077fada1111a24a0aa08bb1e76699c9ce49876af722441845654",
|
||||
|
||||
@@ -1,3 +1,57 @@
|
||||
from .api import AsyncPoolManager
|
||||
from .api import request, blocking_request
|
||||
import trio
|
||||
|
||||
from ._http import AsyncPoolManager, PoolManager
|
||||
from ._http._backends import TrioBackend
|
||||
|
||||
from .import _http
|
||||
|
||||
__all__ = ["request", "blocking_request"]
|
||||
|
||||
async def request(
|
||||
method,
|
||||
url,
|
||||
timeout,
|
||||
*,
|
||||
body=None,
|
||||
headers=None,
|
||||
preload_content=False,
|
||||
pool=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Returns a Response object, to be awaited."""
|
||||
if not pool:
|
||||
pool = AsyncPoolManager(backend=TrioBackend())
|
||||
return await pool.urlopen(
|
||||
method=method,
|
||||
url=url,
|
||||
headers=headers,
|
||||
preload_content=preload_content,
|
||||
body=body,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
||||
def blocking_request(
|
||||
method,
|
||||
url,
|
||||
timeout,
|
||||
*,
|
||||
body=None,
|
||||
headers=None,
|
||||
preload_content=False,
|
||||
pool=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Returns a Response object."""
|
||||
if not pool:
|
||||
pool = PoolManager()
|
||||
with pool as http:
|
||||
r = http.urlopen(
|
||||
method=method,
|
||||
url=url,
|
||||
headers=headers,
|
||||
preload_content=preload_content,
|
||||
body=body,
|
||||
**kwargs
|
||||
)
|
||||
return r
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
import trio
|
||||
|
||||
from ._http import AsyncPoolManager, PoolManager
|
||||
from ._http._backends import TrioBackend
|
||||
|
||||
async def request(
|
||||
method,
|
||||
url,
|
||||
timeout,
|
||||
*,
|
||||
body=None,
|
||||
headers=None,
|
||||
preload_content=False,
|
||||
pool=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Returns a Response object, to be awaited."""
|
||||
if not pool:
|
||||
pool = AsyncPoolManager(backend=TrioBackend())
|
||||
return await pool.urlopen(
|
||||
method=method,
|
||||
url=url,
|
||||
headers=headers,
|
||||
preload_content=preload_content,
|
||||
body=body,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
||||
def blocking_request(
|
||||
method,
|
||||
url,
|
||||
timeout,
|
||||
*,
|
||||
body=None,
|
||||
headers=None,
|
||||
preload_content=False,
|
||||
pool=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Returns a Response object."""
|
||||
if not pool:
|
||||
pool = PoolManager()
|
||||
with pool as http:
|
||||
r = http.urlopen(
|
||||
method=method,
|
||||
url=url,
|
||||
headers=headers,
|
||||
preload_content=preload_content,
|
||||
body=body,
|
||||
**kwargs
|
||||
)
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user