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

@@ -2,7 +2,7 @@ use std::fmt::{self, Display};
use std::str::FromStr;
use header::{Header, HeaderFormat};
use header::parsing::{from_one_raw_str, from_one_comma_delimited};
use header::parsing::{from_one_raw_str, from_comma_delimited};
/// `Range` header, defined in [RFC7233](https://tools.ietf.org/html/rfc7233#section-3.1)
///
@@ -130,7 +130,7 @@ impl FromStr for Range {
match (iter.next(), iter.next()) {
(Some("bytes"), Some(ranges)) => {
match from_one_comma_delimited(ranges.as_bytes()) {
match from_comma_delimited(&[ranges]) {
Ok(ranges) => {
if ranges.is_empty() {
return Err(::Error::Header);