fix(headers): correctly handle repeated headers

HeaderX: a
    HeaderX: b

MUST be interpreted as

    HeaderX: a, b

See: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

Fixes #683
This commit is contained in:
Steven Allen
2016-03-11 15:03:35 -05:00
parent 028f586432
commit 70c6914217
6 changed files with 41 additions and 27 deletions

View File

@@ -156,8 +156,15 @@ macro_rules! test_header {
assert_eq!(val.ok(), typed);
// Test formatting
if typed.is_some() {
let res: &str = str::from_utf8($raw[0]).unwrap();
assert_eq!(format!("{}", typed.unwrap()), res);
let raw = &($raw)[..];
let mut iter = raw.iter().map(|b|str::from_utf8(&b[..]).unwrap());
let mut joined = String::new();
joined.push_str(iter.next().unwrap());
for s in iter {
joined.push_str(", ");
joined.push_str(s);
}
assert_eq!(format!("{}", typed.unwrap()), joined);
}
}
}