diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-05-18 20:10:25 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-18 20:10:25 -0600 |
commit | 2b92efa64501320955979a92de39c70b6734f835 (patch) | |
tree | 699473092934d5f221a440c235e9858cce17d5a3 /ext/http/http_next.rs | |
parent | 5b0752234993ee69e47c32db478d2a296f73f396 (diff) |
feat(ext/http): Add support for trailers w/internal API (HTTP/2 only) (#19182)
Necessary for #3326.
Requested in #10214 as well.
Diffstat (limited to 'ext/http/http_next.rs')
-rw-r--r-- | ext/http/http_next.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/http/http_next.rs b/ext/http/http_next.rs index 34281ee92..30a8c9d51 100644 --- a/ext/http/http_next.rs +++ b/ext/http/http_next.rs @@ -318,6 +318,22 @@ pub fn op_http_set_response_headers( } } +#[op] +pub fn op_http_set_response_trailers( + slab_id: SlabId, + trailers: Vec<(ByteString, ByteString)>, +) { + let mut http = slab_get(slab_id); + let mut trailer_map: HeaderMap = HeaderMap::with_capacity(trailers.len()); + for (name, value) in trailers { + // These are valid latin-1 strings + let name = HeaderName::from_bytes(&name).unwrap(); + let value = HeaderValue::from_bytes(&value).unwrap(); + trailer_map.append(name, value); + } + *http.trailers().borrow_mut() = Some(trailer_map); +} + fn is_request_compressible(headers: &HeaderMap) -> Compression { let Some(accept_encoding) = headers.get(ACCEPT_ENCODING) else { return Compression::None; |