Questions tagged [httpx]

HTTPX is a fully featured HTTP client for Python 3, which provides sync and async APIs, and support for both HTTP/1.1 and HTTP/2.

HTTPX is a fully featured HTTP client for Python 3, which provides sync and async APIs, and support for both HTTP/1.1 and HTTP/2. For more details, please check the HTTPX website.

162 questions
0
votes
1 answer

Python Async function not working. Just keep running

The problem is When running the code it doesn't finish it just print the index and stops at the end What I am doing wrong? limits = httpx.Limits(max_keepalive_connections=5, max_connections=10) finalList=[] async def getVouchDetails(link, client): …
0
votes
1 answer

httpx.RemoteProtocolError while processign 1Gb+ file

My code downloads huge file with httpx and process it's chunks on the fly async with httpx.AsyncClient() as client: async with client.stream("GET", self.url, follow_redirects=True, timeout=60) as stream: async for chunk in…
Serge
  • 1,416
  • 1
  • 15
  • 21
0
votes
0 answers

How to asynchronously query dynamodb table using python

I am using the aiodynamo library to query a dynamodb table, but the current code I have is slow. Can someone please suggest modifications or point out errors? The table is queried with partitionKey=symbol and sortKey=EffectiveTime where the sortKey…
0
votes
3 answers

How do I make sure httpx calls are run in parallel?

I was recommended httpx as a way to perform api requests in parallel, with a nice api like requests. my code import asyncio import time import httpx async def main(): t0 = time.time() usernames = [ "author", "abtinf", …
Harry Moreno
  • 10,231
  • 7
  • 64
  • 116
0
votes
1 answer

httpx/URL is changing original URL

If I have %20 in URL before, it ends up with + in the code. url='http://www.example.com?param=a%20b' url=URL(url) url=url.copy_merge_params(params={}) In QueryParams.str it's invoking urlencode() without any additional arguments. Is there a way to…
aikipooh
  • 137
  • 1
  • 19
0
votes
0 answers

How to reuse class in async Django view

I've made a class with requests inherited from httpx: class URLRequest: """URL request class.""" def __init__(self, client): self.client = httpx.AsyncClient(follow_redirects=True) async def close_session(self): """Close…
Vitalii Mytenko
  • 544
  • 5
  • 20
0
votes
1 answer

httpx async http2 errorhandling slow down and retry on error

When server gets overloaded it stats dropping, but my program then drops everything left in jobs. 2-300 lines of the below error is common (same last_stream_id): 20230428143422.761|ERROR|gitlab.py:293|gitlab failed us:…
MortenB
  • 2,749
  • 1
  • 31
  • 35
0
votes
1 answer

How to check call count in HTTPX library

Using requests_mock I can check if it was called with call_count attribute like in the example below: def test_foo( self, response, mock_service, ): assert mock_service.call_count == 1 But now I'm using httpx library. How I can…
Tony
  • 3
  • 2
0
votes
1 answer

What exceptions can be raised by Python HTTPX's json() method?

The excellent Python HTTPX package has a .json() method for conveniently decoding resposnes that are in JSON format. But the documentation does not mention what exceptions can be raised by .json(), and even looking through the code, it is not…
mhucka
  • 2,143
  • 26
  • 41
0
votes
1 answer

Disable ssl verification on a third party module using HTTPX

I'm using a module that uses httpx to make a request. Because of my company's network policy, I get a CERTIFICATE_VERIFY_FAILED every time I try to run my code. The data I'm sending and receiving in the request is not sensitive so I want to disable…
João Areias
  • 1,192
  • 11
  • 41
0
votes
0 answers

Response failing in httpx but not in requests

I am making a POST request to a URL using 'httpx' library. However, I get a 401 unauthorized error with my below request cert = os.path.realpath('./certs/certificate.pem') key = os.path.realpath('./certs/key.pem') context =…
Vishnukk
  • 524
  • 2
  • 11
  • 27
0
votes
0 answers

How to do async python with max concurrency, sequential processing, and error handling?

I am working on a hook that will process a batch of http requests asynchronously. The hook should be able to do the following: Send requests concurrently up to a max concurrency Process requests in the order of the original request list Raise an…
JTa
  • 181
  • 1
  • 12
0
votes
1 answer

Can't test Post request with FastAPI & Pytest

I'm trying to test my /login API with FastAPI's Testclient. But when I pass data to the post api. It shows, 422 error with content username and password fields are required. API: @router.post('/token', response_model=schemas.Token) async def…
Fahad Md Kamal
  • 243
  • 6
  • 20
0
votes
1 answer

proxies+verify kwargs break HTTP/2 in httpx

Versions: httpx 0.23.3 and httpcore 0.16.3. import httpx s=httpx.Client( http2=True, proxies='http://127.0.0.1:9000', verify=False ) r=s.get('https://in.indeed.com') print(r.http_version) Commenting out proxies/verify gives HTTP/2. The proxy…
aikipooh
  • 137
  • 1
  • 19
0
votes
0 answers

I want to send a POST request with really long headers. Is there an easy way to do this for a string until the entire sting has been sent in python?

params = { "description": description } The description variable above is about 9000 characters, which is too long for the API I want to POST to. I think sending multiple requests in small pieces would work, but I want to do this programmatically to…