Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/proto/h1/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Encoder {

if allowed_set.contains(name) {
if is_valid_trailer_field(name) {
allowed_trailers.insert(name, value);
allowed_trailers.append(name, value);
} else {
debug!("trailer field is not valid: {}", &name);
}
Expand Down Expand Up @@ -567,6 +567,32 @@ mod tests {
);
}

#[test]
fn chunked_with_duplicate_trailer_values() {
let encoder = Encoder::chunked();
let trailers = vec![HeaderName::from_static("chunky-trailer")];
let encoder = encoder.into_chunked_with_trailing_fields(trailers);

let mut headers = HeaderMap::new();
headers.append(
HeaderName::from_static("chunky-trailer"),
HeaderValue::from_static("first"),
);
headers.append(
HeaderName::from_static("chunky-trailer"),
HeaderValue::from_static("second"),
);

let buf1 = encoder.encode_trailers::<&[u8]>(headers, false).unwrap();

let mut dst = Vec::new();
dst.put(buf1);
assert_eq!(
dst,
b"0\r\nchunky-trailer: first\r\nchunky-trailer: second\r\n\r\n"
);
}

#[test]
fn chunked_with_no_trailer_header() {
let encoder = Encoder::chunked();
Expand Down
Loading