-
-
Notifications
You must be signed in to change notification settings - Fork 911
Closed
Labels
Description
Discussed in #1593
Originally posted by sam-kleiner August 4, 2022
I would like to add support for HTTP trailers.
This is already supported in the h11 library so adding this is fairly easy.
I wrote a POC with tests
Uses for this in include returning hashes for validation, expire info, errors during stream, etc.
Here is the output (using my code) of a curl command getting streaming json where an error happens before all json is sent to the client
$ curl -v -N http://localhost:8000 --raw
* Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< date: Wed, 03 Aug 2022 22:37:47 GMT
< server: uvicorn
< content-type: application/json
< trailer: X-Error
< Transfer-Encoding: chunked
<
c
{"message":[
8
"bEHWA",
8
"xuyBF",
8
"14vBZ",
8
"f4Jyp",
8
"uadVV",
8
"oTbyL",
8
"aZcZr",
0
x-error: Exception message here
* Connection #0 to host localhost left intact
Reactions are currently unavailable