Skip to content
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

Expose trailing headers #157

Closed
sagebind opened this issue Jan 22, 2020 · 1 comment
Closed

Expose trailing headers #157

sagebind opened this issue Jan 22, 2020 · 1 comment
Assignees
Labels
feature A new feature!

Comments

@sagebind
Copy link
Owner

Provide a way for users to access "trailer headers" as defined in RFC 7230. Trailer headers are headers delivered after the response body has been consumed with chunked encoding.

Accessing the trailer is tricky because it can make APIs look awkward since it violates the traditional flow of a response. Here's one possible API:

// Existing trait
pub trait ResponseExt {
    // New method, returns an object that provides access to the trailer, if a trailer
    // is expected.
    fn trailer(&self) -> Option<&Trailer>;
}

pub struct Trailer {
    // ...
}

impl Trailer {
    // Get the currently available trailer headers. May be None if the trailer has
    // not yet arrived.
    pub fn headers(&self) -> Option<&HeaderMap>;

    // Block the current thread until the trailer is received, or the transfer
    // completes, whichever comes first.
    pub fn wait(&self);

    // Wait for the trailer to arrive asynchronously.
    pub async fn arrive(&self);
}
@sagebind sagebind added the feature A new feature! label Jan 22, 2020
@sagebind sagebind self-assigned this Nov 14, 2020
sagebind added a commit that referenced this issue May 13, 2021
Add new API for accessing response trailer headers.

See #157.
@sagebind
Copy link
Owner Author

This is now available in the 1.4.0 release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature!
Projects
None yet
Development

No branches or pull requests

1 participant