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:
@@ -1,7 +1,7 @@
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use header::{Header, HeaderFormat};
|
||||
use header::parsing::{from_one_comma_delimited, fmt_comma_delimited};
|
||||
use header::parsing::{from_comma_delimited, fmt_comma_delimited};
|
||||
|
||||
/// `Cache-Control` header, defined in [RFC7234](https://tools.ietf.org/html/rfc7234#section-5.2)
|
||||
///
|
||||
@@ -55,10 +55,7 @@ impl Header for CacheControl {
|
||||
}
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> ::Result<CacheControl> {
|
||||
let directives = raw.iter()
|
||||
.filter_map(|line| from_one_comma_delimited(&line[..]).ok())
|
||||
.collect::<Vec<Vec<CacheDirective>>>()
|
||||
.concat();
|
||||
let directives = try!(from_comma_delimited(raw));
|
||||
if !directives.is_empty() {
|
||||
Ok(CacheControl(directives))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user