crepererum opened a new pull request, #4727:
URL: https://github.com/apache/arrow-rs/pull/4727

   # Which issue does this PR close?
   \-
   
   # Rationale for this change
   HTTP/2 headers can already be sent by the client (and trivially by the 
server as part of the `tonic::Response` object). However the the client doesn't 
expose the response headers yet. They can include debug information like server 
version or other metadata.
   
   Trailers are less commonly used but can include information that is only 
available AFTER the response stream finishes, e.g. "number of scanned files", 
"total rows read from files", etc. Tonic doesn't have a super nice way to write 
them from the server side, but a tower layer makes that possible. Also we have 
to consider non-Rust implementations that can make use of trailers.
   
   People that read the [HTTP/2 spec](https://httpwg.org/specs/rfc7540.html) 
may wonder how headers and trailers are encoded in a stream scenario. Turns out 
that they have their own `HEADERS` message. The first `HEADERS` message 
transmit the HTTP headers, the last one at the stream end (w/ the `END_STREAM` 
flag set) the trailers. Now you may wonder if you could send headers mid-stream 
as well. Now the HTTP/2 spec doesn't seem to disallow that, but:
   
   - neither tonic and tower have a way to do that
   - [this stackoverflow answer](https://stackoverflow.com/a/61556928) suggests 
that this is not allowed because HTTP itself has no semantic for that and 
indeed the HTTP/2 spec say:
     
     > This specification is an alternative to, but does not obsolete, the 
HTTP/1.1 message syntax. **HTTP's existing semantics remain unchanged.**
   
     This is also confirmed by [this stackoverflow 
answer](https://stackoverflow.com/a/44466519).
   
   So I think metadata can only be sent at the beginning and at the end of a 
stream. Everything else would also be a bit of an API mess.
   
   # What changes are included in this PR?
   Wires HTTP/2 headers and trailers into flight client `DoGet` method. Tests 
included.
   
   # Are there any user-facing changes?
   New methods to get headers and trailers.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to