Debian Codegraph @

third_party/rust/headers/src/common/mod.rs

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