refactor(headers): export all headers and utils directly under header

Currently headers are exported at many places. For example you can access
`Transfer-Encoding` header at `header`, `header::common` and
`header::common::transfer_encoding`. Per discussion on IRC with
@seanmonstar and @reem, all contents of headers will be exposed at `header`
directly. Parsing utilities will be exposed at `header::parsing`. Header
macros can now be used from other crates.

This breaks much code using headers. It should use everything it needs
directly from `header::`, encodings are exposed at `header::Encoding::`,
connection options are exposed at `header::ConnectionOption`.
This commit is contained in:
Pyfisch
2015-01-20 13:04:42 +01:00
parent 7a5813b4b2
commit 8d0e5bc302
37 changed files with 223 additions and 272 deletions

View File

@@ -1,11 +1,17 @@
use std::fmt;
use header;
use header::shared;
use method::Method;
#[derive(Clone)]
struct AccessControlRequestMethod(pub Method);
/// The `Access-Control-Request-Method` request header,
/// part of [CORS](http://www.w3.org/TR/cors/).
///
/// > The `Access-Control-Request-Method` header indicates which method will be
/// > used in the actual request as part of the preflight request.
///
/// Spec: www.w3.org/TR/cors/#access-control-request-method-request-header
#[derive(Clone, PartialEq, Show)]
pub struct AccessControlRequestMethod(pub Method);
impl header::Header for AccessControlRequestMethod {
#[inline]
@@ -14,7 +20,7 @@ impl header::Header for AccessControlRequestMethod {
}
fn parse_header(raw: &[Vec<u8>]) -> Option<AccessControlRequestMethod> {
shared::from_one_raw_str(raw).map(AccessControlRequestMethod)
header::parsing::from_one_raw_str(raw).map(AccessControlRequestMethod)
}
}