httpx, unlike requests, sends null query parameters #2704
-
Hi, I've been using In the response = requests.get("https://google.com", params={"q": None})
print(response.request.url) # prints "https://www.google.com/" while in async with httpx.AsyncClient() as client:
response = await client.get("https://google.com", params={"q": None})
print(response.request.url) # prints "https://google.com?q=" From what I see online, the standard is that if a query param is null then it should not be sent at all. I now realize that passing the flag: as part of this issue: #2331 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
FastAPI can accept null as a query parameter value for example server.py from fastapi import FastAPI
app = FastAPI()
@app.get('/')
def root(a: str):
print(f'a={a!r}') curl curl "http://127.0.0.1:8000/?a=" server stdout
If a value doesn't matter or is just blank, the server may use null values, which are valid. |
Beta Was this translation helpful? Give feedback.
FastAPI can accept null as a query parameter value for example
server.py
curl
curl "http://127.0.0.1:8000/?a="
server stdout
If a value doesn't matter or is just blank, the server may use null values, which are valid.
Also see #2712