-
-
Notifications
You must be signed in to change notification settings - Fork 858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trailing Headers #1149
Comments
Interesting related docs on MDN: Example they provide:
|
Be interested to know if there's any good examples of trailing headers actually being used in the wild. The low-level part of this would prob be a trailing headers extension that can be provided to the Transport API, eg... def trailing_headers(headers):
# Callback that is invoked when response trailing headers are included.
...
transport.handle_request(
method=b"GET",
url=(b"https", b"www.example.com", None, b"/"),
headers=[(b"Host", b"www.example.com")],
stream=httpx.ByteStream(b""),
extensions={"trailing_headers": trailing_headers}
) We could then integrate this into httpx without requiring any extra API, by supplying that callback, with an implementation that mutates the response headers. Anyways, I think this is probably all rather unnecessary unless there's clear a good driving use-case that some users are bumping up against, but leaving this all here for possible future reference. |
Ya know what? No. Just no. |
I'd like for this to be reconsidered as the folks behind https://connect.build/ are interested in supporting python clients but this would require trailing header support. |
Okay, we could possibly?...
Could you provide some more context? |
Hi! I'm from @bufbuild and work on the Connect family of RPC libraries. Trailer support would indeed be valuable to us. Really appreciate you even engaging in discussion on this 😻 I'm happy to provide some context, both specific to RPC and generally.
In general, it'd be nice to have a gRPC-compatible package that's built as a thin layer around best-in-class Python HTTP packages - it lets Python developers leverage everything they already know. More generally, trailers are sometimes useful to avoid buffering lots of data. Outside of gRPC's reliance on them, the most common use I've seen is checksumming data - it's nice to send the checksum as a trailer, rather than buffering and sending it as a header. |
Okay, so I'm up for putting time into this. I'm particularly interested in being able to support gRPC. Even though that's a niche use-case for our audience as a whole, it's also a great example of pushing hard against the lower-level bits of API, and ensuring that |
Does anyone have any examples of public URLs that return trailing headers? I can also hack something, but it'd be nice if there's an easy place to point at from demonstration purposes. |
First pass onto this. ☝️ |
@tomchristie what happened to this? It looks like encode/httpcore#582 was closed without being merged. Anyhow, I have a real world use case for sending Trailing Headers, as AWS use them for errors in streaming responses from Lambda: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html#runtimes-custom-response-streaming |
Looks like it was closed off as low priority. |
One HTTP/1.1 feature that we don't currently support is trailing headers.
Hardly a high priority since it's seems so rarely used, but it might be worth our while someday.
It'd be interesting to hear from folks who do have use-cases here.
One option at the Transport API layer might be to update the
AsyncByteStream
/SyncByteStream
APIs in order to handle this, without affecting the majority of code that doesn't expect or care about trailing headers, for example...At the
httpx
level we could expose this information by mutating theresponse.headers
once the stream has been iterated over.The text was updated successfully, but these errors were encountered: