I have a simple HTTP API server
from typing import Dict
import uvicorn
from fastapi import FastAPI
app = FastAPI()
@app.post("/data/{uid}")
def data_post(uid: str, data: Dict):
print(f"recieved data for {uid}: {data}")
if __name__ == "__main__":
uvicorn.run(app)
Currently I am running it with uvicorn but this is not a requirement (other ASGI servers could work as well)
My problem is that the clients that call this API use HTTP 1.0 but the server responds with HTTP 1.1
curl -v --http1.0 -H "Content-Type: application/json" -d '{"a": 123, "b":"test"}' localhost:8000/data/123abc
* Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> POST /data/123abc HTTP/1.0
> Host: localhost:8000
> User-Agent: curl/7.77.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 22
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< date: Mon, 24 Jan 2022 13:43:12 GMT
< server: uvicorn
< content-length: 4
< content-type: application/json
< Connection: close
<
* Closing connection 0
I would like to know if there is a way to configure uvicorn to use HTTP 1.0 or if there is another ASGI server that can be used with FastAPI applications that can achieve this.
Unfortunatelly I can not change the clients (they are a third party product) and currently they do not support HTTP 1.1.