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,22 +1,22 @@
use header::{self, shared};
use header::{self, Encoding, QualityItem};
/// The `Accept-Encoding` header
///
/// The `Accept-Encoding` header can be used by clients to indicate what
/// response encodings they accept.
#[derive(Clone, PartialEq, Show)]
pub struct AcceptEncoding(pub Vec<shared::QualityItem<shared::Encoding>>);
pub struct AcceptEncoding(pub Vec<QualityItem<Encoding>>);
impl_list_header!(AcceptEncoding,
"Accept-Encoding",
Vec<shared::QualityItem<shared::Encoding>>);
Vec<QualityItem<Encoding>>);
#[test]
fn test_parse_header() {
let a: AcceptEncoding = header::Header::parse_header([b"gzip;q=1.0, identity; q=0.5".to_vec()].as_slice()).unwrap();
let b = AcceptEncoding(vec![
shared::QualityItem{item: shared::Gzip, quality: 1f32},
shared::QualityItem{item: shared::Identity, quality: 0.5f32},
QualityItem{item: Encoding::Gzip, quality: 1f32},
QualityItem{item: Encoding::Identity, quality: 0.5f32},
]);
assert_eq!(a, b);
}