Merge pull request #247 from hyperium/fix-header-fmt
fix(header): fix fmt_header outputs of several headers
This commit is contained in:
@@ -72,7 +72,7 @@ pub enum CacheDirective {
|
|||||||
impl fmt::String for CacheDirective {
|
impl fmt::String for CacheDirective {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
use self::CacheDirective::*;
|
use self::CacheDirective::*;
|
||||||
match *self {
|
fmt::String::fmt(match *self {
|
||||||
NoCache => "no-cache",
|
NoCache => "no-cache",
|
||||||
NoStore => "no-store",
|
NoStore => "no-store",
|
||||||
NoTransform => "no-transform",
|
NoTransform => "no-transform",
|
||||||
@@ -91,7 +91,7 @@ impl fmt::String for CacheDirective {
|
|||||||
Extension(ref name, None) => &name[],
|
Extension(ref name, None) => &name[],
|
||||||
Extension(ref name, Some(ref arg)) => return write!(f, "{}={}", name, arg),
|
Extension(ref name, Some(ref arg)) => return write!(f, "{}={}", name, arg),
|
||||||
|
|
||||||
}.fmt(f)
|
}, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt::{self, Show};
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use header::shared::util::{from_comma_delimited, fmt_comma_delimited};
|
use header::shared::util::{from_comma_delimited, fmt_comma_delimited};
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ pub struct Connection(pub Vec<ConnectionOption>);
|
|||||||
deref!(Connection => Vec<ConnectionOption>);
|
deref!(Connection => Vec<ConnectionOption>);
|
||||||
|
|
||||||
/// Values that can be in the `Connection` header.
|
/// Values that can be in the `Connection` header.
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq, Show)]
|
||||||
pub enum ConnectionOption {
|
pub enum ConnectionOption {
|
||||||
/// The `keep-alive` connection value.
|
/// The `keep-alive` connection value.
|
||||||
KeepAlive,
|
KeepAlive,
|
||||||
@@ -49,12 +49,6 @@ impl fmt::String for ConnectionOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Show for ConnectionOption {
|
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
self.to_string().fmt(fmt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Header for Connection {
|
impl Header for Connection {
|
||||||
fn header_name(_: Option<Connection>) -> &'static str {
|
fn header_name(_: Option<Connection>) -> &'static str {
|
||||||
"Connection"
|
"Connection"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt::{self, String};
|
use std::fmt;
|
||||||
use header::shared::util::from_one_raw_str;
|
use header::shared::util::from_one_raw_str;
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
|
|
||||||
@@ -24,8 +24,7 @@ impl Header for ContentType {
|
|||||||
|
|
||||||
impl HeaderFormat for ContentType {
|
impl HeaderFormat for ContentType {
|
||||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let ContentType(ref value) = *self;
|
fmt::String::fmt(&self.0, fmt)
|
||||||
value.fmt(fmt)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::fmt::{self, Show};
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use time::Tm;
|
use time::Tm;
|
||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
@@ -7,7 +7,7 @@ use header::shared::time::tm_from_str;
|
|||||||
|
|
||||||
// Egh, replace as soon as something better than time::Tm exists.
|
// Egh, replace as soon as something better than time::Tm exists.
|
||||||
/// The `Date` header field.
|
/// The `Date` header field.
|
||||||
#[derive(Copy, PartialEq, Clone)]
|
#[derive(Copy, PartialEq, Clone, Show)]
|
||||||
pub struct Date(pub Tm);
|
pub struct Date(pub Tm);
|
||||||
|
|
||||||
deref!(Date => Tm);
|
deref!(Date => Tm);
|
||||||
@@ -25,11 +25,12 @@ impl Header for Date {
|
|||||||
|
|
||||||
impl HeaderFormat for Date {
|
impl HeaderFormat for Date {
|
||||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let tm = **self;
|
let tm = self.0;
|
||||||
match tm.tm_utcoff {
|
let tm = match tm.tm_utcoff {
|
||||||
0 => tm.rfc822().fmt(fmt),
|
0 => tm,
|
||||||
_ => tm.to_utc().rfc822().fmt(fmt)
|
_ => tm.to_utc(),
|
||||||
}
|
};
|
||||||
|
fmt::String::fmt(&tm.rfc822(), fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::fmt::{self, Show};
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use time::Tm;
|
use time::Tm;
|
||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
@@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str;
|
|||||||
use header::shared::time::tm_from_str;
|
use header::shared::time::tm_from_str;
|
||||||
|
|
||||||
/// The `Expires` header field.
|
/// The `Expires` header field.
|
||||||
#[derive(Copy, PartialEq, Clone)]
|
#[derive(Copy, PartialEq, Clone, Show)]
|
||||||
pub struct Expires(pub Tm);
|
pub struct Expires(pub Tm);
|
||||||
|
|
||||||
deref!(Expires => Tm);
|
deref!(Expires => Tm);
|
||||||
@@ -24,11 +24,12 @@ impl Header for Expires {
|
|||||||
|
|
||||||
impl HeaderFormat for Expires {
|
impl HeaderFormat for Expires {
|
||||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let tm = **self;
|
let tm = self.0;
|
||||||
match tm.tm_utcoff {
|
let tm = match tm.tm_utcoff {
|
||||||
0 => tm.rfc822().fmt(fmt),
|
0 => tm,
|
||||||
_ => tm.to_utc().rfc822().fmt(fmt)
|
_ => tm.to_utc(),
|
||||||
}
|
};
|
||||||
|
fmt::String::fmt(&tm.rfc822(), fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::fmt::{self, Show};
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use time::Tm;
|
use time::Tm;
|
||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
@@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str;
|
|||||||
use header::shared::time::tm_from_str;
|
use header::shared::time::tm_from_str;
|
||||||
|
|
||||||
/// The `If-Modified-Since` header field.
|
/// The `If-Modified-Since` header field.
|
||||||
#[derive(Copy, PartialEq, Clone)]
|
#[derive(Copy, PartialEq, Clone, Show)]
|
||||||
pub struct IfModifiedSince(pub Tm);
|
pub struct IfModifiedSince(pub Tm);
|
||||||
|
|
||||||
deref!(IfModifiedSince => Tm);
|
deref!(IfModifiedSince => Tm);
|
||||||
@@ -24,11 +24,12 @@ impl Header for IfModifiedSince {
|
|||||||
|
|
||||||
impl HeaderFormat for IfModifiedSince {
|
impl HeaderFormat for IfModifiedSince {
|
||||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let tm = **self;
|
let tm = self.0;
|
||||||
match tm.tm_utcoff {
|
let tm = match tm.tm_utcoff {
|
||||||
0 => tm.rfc822().fmt(fmt),
|
0 => tm,
|
||||||
_ => tm.to_utc().rfc822().fmt(fmt)
|
_ => tm.to_utc(),
|
||||||
}
|
};
|
||||||
|
fmt::String::fmt(&tm.rfc822(), fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::fmt::{self, Show};
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use time::Tm;
|
use time::Tm;
|
||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
@@ -6,7 +6,7 @@ use header::shared::util::from_one_raw_str;
|
|||||||
use header::shared::time::tm_from_str;
|
use header::shared::time::tm_from_str;
|
||||||
|
|
||||||
/// The `LastModified` header field.
|
/// The `LastModified` header field.
|
||||||
#[derive(Copy, PartialEq, Clone)]
|
#[derive(Copy, PartialEq, Clone, Show)]
|
||||||
pub struct LastModified(pub Tm);
|
pub struct LastModified(pub Tm);
|
||||||
|
|
||||||
deref!(LastModified => Tm);
|
deref!(LastModified => Tm);
|
||||||
@@ -24,11 +24,12 @@ impl Header for LastModified {
|
|||||||
|
|
||||||
impl HeaderFormat for LastModified {
|
impl HeaderFormat for LastModified {
|
||||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let tm = **self;
|
let tm = self.0;
|
||||||
match tm.tm_utcoff {
|
let tm = match tm.tm_utcoff {
|
||||||
0 => tm.rfc822().fmt(fmt),
|
0 => tm,
|
||||||
_ => tm.to_utc().rfc822().fmt(fmt)
|
_ => tm.to_utc(),
|
||||||
}
|
};
|
||||||
|
fmt::String::fmt(&tm.rfc822(), fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt::{self, Show};
|
use std::fmt;
|
||||||
use header::shared::util::from_one_raw_str;
|
use header::shared::util::from_one_raw_str;
|
||||||
|
|
||||||
/// The `Location` header.
|
/// The `Location` header.
|
||||||
@@ -30,8 +30,7 @@ impl Header for Location {
|
|||||||
|
|
||||||
impl HeaderFormat for Location {
|
impl HeaderFormat for Location {
|
||||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let Location(ref value) = *self;
|
fmt.write_str(&*self.0)
|
||||||
value.fmt(fmt)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt::{self, Show};
|
use std::fmt;
|
||||||
use header::shared::util::from_one_raw_str;
|
use header::shared::util::from_one_raw_str;
|
||||||
|
|
||||||
/// The `Server` header field.
|
/// The `Server` header field.
|
||||||
@@ -22,8 +22,7 @@ impl Header for Server {
|
|||||||
|
|
||||||
impl HeaderFormat for Server {
|
impl HeaderFormat for Server {
|
||||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let Server(ref value) = *self;
|
fmt.write_str(&*self.0)
|
||||||
value.fmt(fmt)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ deref!(TransferEncoding => Vec<Encoding>);
|
|||||||
/// # use hyper::header::Headers;
|
/// # use hyper::header::Headers;
|
||||||
/// # let mut headers = Headers::new();
|
/// # let mut headers = Headers::new();
|
||||||
/// headers.set(TransferEncoding(vec![Gzip, Chunked]));
|
/// headers.set(TransferEncoding(vec![Gzip, Chunked]));
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq, Show)]
|
||||||
pub enum Encoding {
|
pub enum Encoding {
|
||||||
/// The `chunked` encoding.
|
/// The `chunked` encoding.
|
||||||
Chunked,
|
Chunked,
|
||||||
@@ -59,12 +59,6 @@ impl fmt::String for Encoding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Show for Encoding {
|
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
self.to_string().fmt(fmt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Encoding {
|
impl FromStr for Encoding {
|
||||||
fn from_str(s: &str) -> Option<Encoding> {
|
fn from_str(s: &str) -> Option<Encoding> {
|
||||||
match s {
|
match s {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt::{self, Show};
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use header::shared::util::{from_comma_delimited, fmt_comma_delimited};
|
use header::shared::util::{from_comma_delimited, fmt_comma_delimited};
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ pub struct Upgrade(pub Vec<Protocol>);
|
|||||||
deref!(Upgrade => Vec<Protocol>);
|
deref!(Upgrade => Vec<Protocol>);
|
||||||
|
|
||||||
/// Protocol values that can appear in the Upgrade header.
|
/// Protocol values that can appear in the Upgrade header.
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq, Show)]
|
||||||
pub enum Protocol {
|
pub enum Protocol {
|
||||||
/// The websocket protocol.
|
/// The websocket protocol.
|
||||||
WebSocket,
|
WebSocket,
|
||||||
@@ -38,12 +38,6 @@ impl fmt::String for Protocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Show for Protocol {
|
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
self.to_string().fmt(fmt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Header for Upgrade {
|
impl Header for Upgrade {
|
||||||
fn header_name(_: Option<Upgrade>) -> &'static str {
|
fn header_name(_: Option<Upgrade>) -> &'static str {
|
||||||
"Upgrade"
|
"Upgrade"
|
||||||
|
|||||||
Reference in New Issue
Block a user