Update all common headers for the new Header trait split
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt::{mod, Show};
|
||||
use std::str::from_utf8;
|
||||
use mime::Mime;
|
||||
@@ -49,7 +49,9 @@ impl Header for Accept {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for Accept {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Accept(ref value) = *self;
|
||||
let last = value.len() - 1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt::{mod, Show};
|
||||
use super::{from_comma_delimited, fmt_comma_delimited};
|
||||
use std::from_str::FromStr;
|
||||
@@ -53,7 +53,9 @@ impl Header for Connection {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Connection> {
|
||||
from_comma_delimited(raw).map(|vec| Connection(vec))
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for Connection {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Connection(ref parts) = *self;
|
||||
fmt_comma_delimited(fmt, parts[])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::fmt::{mod, Show};
|
||||
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use super::util::from_one_raw_str;
|
||||
|
||||
/// The `Content-Length` header.
|
||||
@@ -17,7 +17,9 @@ impl Header for ContentLength {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<ContentLength> {
|
||||
from_one_raw_str(raw).map(|u| ContentLength(u))
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for ContentLength {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let ContentLength(ref value) = *self;
|
||||
value.fmt(fmt)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt::{mod, Show};
|
||||
use super::util::from_one_raw_str;
|
||||
use mime::Mime;
|
||||
@@ -18,7 +18,9 @@ impl Header for ContentType {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<ContentType> {
|
||||
from_one_raw_str(raw).map(|mime| ContentType(mime))
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for ContentType {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let ContentType(ref value) = *self;
|
||||
value.fmt(fmt)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt::{mod, Show};
|
||||
use super::util::from_one_raw_str;
|
||||
use std::from_str::FromStr;
|
||||
@@ -17,7 +17,9 @@ impl Header for Date {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Date> {
|
||||
from_one_raw_str(raw)
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for Date {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.fmt(fmt)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use Port;
|
||||
use std::fmt::{mod, Show};
|
||||
use super::util::from_one_raw_str;
|
||||
@@ -61,7 +61,9 @@ impl Header for Host {
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for Host {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.port {
|
||||
None | Some(80) | Some(443) => self.hostname.fmt(fmt),
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt::{mod, Show};
|
||||
use super::util::from_one_raw_str;
|
||||
|
||||
/// The `Location` header.
|
||||
///
|
||||
/// The Location response-header field is used to redirect the recipient to
|
||||
/// a location other than the Request-URI for completion of the request or identification
|
||||
/// of a new resource. For 201 (Created) responses, the Location is that of the new
|
||||
/// resource which was created by the request. For 3xx responses, the location SHOULD
|
||||
/// indicate the server's preferred URI for automatic redirection to the resource.
|
||||
/// The Location response-header field is used to redirect the recipient to
|
||||
/// a location other than the Request-URI for completion of the request or identification
|
||||
/// of a new resource. For 201 (Created) responses, the Location is that of the new
|
||||
/// resource which was created by the request. For 3xx responses, the location SHOULD
|
||||
/// indicate the server's preferred URI for automatic redirection to the resource.
|
||||
/// The field value consists of a single absolute URI.
|
||||
///
|
||||
/// Currently is just a String, but it should probably become a better type,
|
||||
@@ -24,7 +24,9 @@ impl Header for Location {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Location> {
|
||||
from_one_raw_str(raw).map(|s| Location(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for Location {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Location(ref value) = *self;
|
||||
value.fmt(fmt)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt::{mod, Show};
|
||||
use super::util::from_one_raw_str;
|
||||
|
||||
@@ -16,7 +16,9 @@ impl Header for Server {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Server> {
|
||||
from_one_raw_str(raw).map(|s| Server(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for Server {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Server(ref value) = *self;
|
||||
value.fmt(fmt)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt;
|
||||
use std::from_str::FromStr;
|
||||
use super::{from_comma_delimited, fmt_comma_delimited};
|
||||
@@ -75,7 +75,9 @@ impl Header for TransferEncoding {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<TransferEncoding> {
|
||||
from_comma_delimited(raw).map(|vec| TransferEncoding(vec))
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for TransferEncoding {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let TransferEncoding(ref parts) = *self;
|
||||
fmt_comma_delimited(fmt, parts[])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt::{mod, Show};
|
||||
use super::{from_comma_delimited, fmt_comma_delimited};
|
||||
use std::from_str::FromStr;
|
||||
@@ -42,7 +42,9 @@ impl Header for Upgrade {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Upgrade> {
|
||||
from_comma_delimited(raw).map(|vec| Upgrade(vec))
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for Upgrade {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Upgrade(ref parts) = *self;
|
||||
fmt_comma_delimited(fmt, parts[])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use header::Header;
|
||||
use header::{Header, HeaderFormat};
|
||||
use std::fmt::{mod, Show};
|
||||
use super::util::from_one_raw_str;
|
||||
|
||||
@@ -16,7 +16,9 @@ impl Header for UserAgent {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<UserAgent> {
|
||||
from_one_raw_str(raw).map(|s| UserAgent(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for UserAgent {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let UserAgent(ref value) = *self;
|
||||
value.fmt(fmt)
|
||||
|
||||
Reference in New Issue
Block a user