headers_accept_encoding/common/
mod.rs

1//! A Collection of Header implementations for common HTTP Headers.
2//!
3//! ## Mime
4//!
5//! Several header fields use MIME values for their contents. Keeping with the
6//! strongly-typed theme, the [mime](https://docs.rs/mime) crate
7//! is used, such as `ContentType(pub Mime)`.
8
9//pub use self::accept_charset::AcceptCharset;
10pub use self::accept_encoding::AcceptEncoding;
11//pub use self::accept_language::AcceptLanguage;
12pub use self::accept_ranges::AcceptRanges;
13//pub use self::accept::Accept;
14pub use self::access_control_allow_credentials::AccessControlAllowCredentials;
15pub use self::access_control_allow_headers::AccessControlAllowHeaders;
16pub use self::access_control_allow_methods::AccessControlAllowMethods;
17pub use self::access_control_allow_origin::AccessControlAllowOrigin;
18pub use self::access_control_expose_headers::AccessControlExposeHeaders;
19pub use self::access_control_max_age::AccessControlMaxAge;
20pub use self::access_control_request_headers::AccessControlRequestHeaders;
21pub use self::access_control_request_method::AccessControlRequestMethod;
22pub use self::age::Age;
23pub use self::allow::Allow;
24pub use self::authorization::Authorization;
25pub use self::cache_control::CacheControl;
26pub use self::connection::Connection;
27pub use self::content_coding::ContentCoding;
28pub use self::content_disposition::ContentDisposition;
29pub use self::content_encoding::ContentEncoding;
30//pub use self::content_language::ContentLanguage;
31pub use self::content_length::ContentLength;
32pub use self::content_location::ContentLocation;
33pub use self::content_range::ContentRange;
34pub use self::content_type::ContentType;
35pub use self::cookie::Cookie;
36pub use self::date::Date;
37pub use self::etag::ETag;
38pub use self::expect::Expect;
39pub use self::expires::Expires;
40//pub use self::from::From;
41pub use self::host::Host;
42pub use self::if_match::IfMatch;
43pub use self::if_modified_since::IfModifiedSince;
44pub use self::if_none_match::IfNoneMatch;
45pub use self::if_range::IfRange;
46pub use self::if_unmodified_since::IfUnmodifiedSince;
47//pub use self::last_event_id::LastEventId;
48pub use self::last_modified::LastModified;
49//pub use self::link::{Link, LinkValue, RelationType, MediaDesc};
50pub use self::location::Location;
51pub use self::origin::Origin;
52pub use self::pragma::Pragma;
53//pub use self::prefer::{Prefer, Preference};
54//pub use self::preference_applied::PreferenceApplied;
55pub use self::proxy_authorization::ProxyAuthorization;
56pub use self::range::Range;
57pub use self::referer::Referer;
58pub use self::referrer_policy::ReferrerPolicy;
59pub use self::retry_after::RetryAfter;
60pub use self::sec_websocket_accept::SecWebsocketAccept;
61pub use self::sec_websocket_key::SecWebsocketKey;
62pub use self::sec_websocket_version::SecWebsocketVersion;
63pub use self::server::Server;
64pub use self::set_cookie::SetCookie;
65pub use self::strict_transport_security::StrictTransportSecurity;
66pub use self::te::Te;
67pub use self::transfer_encoding::TransferEncoding;
68pub use self::upgrade::Upgrade;
69pub use self::user_agent::UserAgent;
70pub use self::vary::Vary;
71//pub use self::warning::Warning;
72
73#[cfg(test)]
74fn test_decode<T: ::Header>(values: &[&str]) -> Option<T> {
75    use HeaderMapExt;
76    let mut map = ::http::HeaderMap::new();
77    for val in values {
78        map.append(T::name(), val.parse().unwrap());
79    }
80    map.typed_get()
81}
82
83#[cfg(test)]
84fn test_encode<T: ::Header>(header: T) -> ::http::HeaderMap {
85    use HeaderMapExt;
86    let mut map = ::http::HeaderMap::new();
87    map.typed_insert(header);
88    map
89}
90
91#[cfg(test)]
92macro_rules! bench_header {
93    ($mod:ident, $ty:ident, $value:expr) => {
94        #[cfg(feature = "nightly")]
95        mod $mod {
96            use super::$ty;
97            use HeaderMapExt;
98
99            #[bench]
100            fn bench_decode(b: &mut ::test::Bencher) {
101                let mut map = ::http::HeaderMap::new();
102                map.append(
103                    <$ty as ::Header>::name(),
104                    $value.parse().expect("HeaderValue::from_str($value)"),
105                );
106                b.bytes = $value.len() as u64;
107                b.iter(|| {
108                    map.typed_get::<$ty>().unwrap();
109                });
110            }
111
112            #[bench]
113            fn bench_encode(b: &mut ::test::Bencher) {
114                let mut map = ::http::HeaderMap::new();
115                map.append(
116                    <$ty as ::Header>::name(),
117                    $value.parse().expect("HeaderValue::from_str($value)"),
118                );
119                let typed = map.typed_get::<$ty>().unwrap();
120                b.bytes = $value.len() as u64;
121                b.iter(|| {
122                    map.typed_insert(typed.clone());
123                    map.clear();
124                });
125            }
126        }
127    };
128}
129
130//mod accept;
131//mod accept_charset;
132mod accept_encoding;
133//mod accept_language;
134mod accept_ranges;
135mod access_control_allow_credentials;
136mod access_control_allow_headers;
137mod access_control_allow_methods;
138mod access_control_allow_origin;
139mod access_control_expose_headers;
140mod access_control_max_age;
141mod access_control_request_headers;
142mod access_control_request_method;
143mod age;
144mod allow;
145pub mod authorization;
146mod cache_control;
147mod connection;
148mod content_coding;
149mod content_disposition;
150mod content_encoding;
151//mod content_language;
152mod content_length;
153mod content_location;
154mod content_range;
155mod content_type;
156mod cookie;
157mod date;
158mod etag;
159mod expect;
160mod expires;
161//mod from;
162mod host;
163mod if_match;
164mod if_modified_since;
165mod if_none_match;
166mod if_range;
167mod if_unmodified_since;
168//mod last_event_id;
169mod last_modified;
170//mod link;
171mod location;
172mod origin;
173mod pragma;
174//mod prefer;
175//mod preference_applied;
176mod proxy_authorization;
177mod range;
178mod referer;
179mod referrer_policy;
180mod retry_after;
181mod sec_websocket_accept;
182mod sec_websocket_key;
183mod sec_websocket_version;
184mod server;
185mod set_cookie;
186mod strict_transport_security;
187mod te;
188mod transfer_encoding;
189mod upgrade;
190mod user_agent;
191mod vary;
192//mod warning;