actix_web/http/header/
mod.rs1use std::fmt;
8
9pub use actix_http::header::*;
17use bytes::{Bytes, BytesMut};
18
19mod accept;
20mod accept_charset;
21mod accept_encoding;
22mod accept_language;
23mod allow;
24mod cache_control;
25mod content_disposition;
26mod content_language;
27mod content_length;
28mod content_range;
29mod content_type;
30mod date;
31mod encoding;
32mod entity;
33mod etag;
34mod expires;
35mod if_match;
36mod if_modified_since;
37mod if_none_match;
38mod if_range;
39mod if_unmodified_since;
40mod last_modified;
41mod macros;
42mod preference;
43mod range;
44
45#[cfg(test)]
46pub(crate) use self::macros::common_header_test;
47pub(crate) use self::macros::{common_header, common_header_test_module};
48pub use self::{
49 accept::Accept,
50 accept_charset::AcceptCharset,
51 accept_encoding::AcceptEncoding,
52 accept_language::AcceptLanguage,
53 allow::Allow,
54 cache_control::{CacheControl, CacheDirective},
55 content_disposition::{ContentDisposition, DispositionParam, DispositionType},
56 content_language::ContentLanguage,
57 content_length::ContentLength,
58 content_range::{ContentRange, ContentRangeSpec},
59 content_type::ContentType,
60 date::Date,
61 encoding::Encoding,
62 entity::EntityTag,
63 etag::ETag,
64 expires::Expires,
65 if_match::IfMatch,
66 if_modified_since::IfModifiedSince,
67 if_none_match::IfNoneMatch,
68 if_range::IfRange,
69 if_unmodified_since::IfUnmodifiedSince,
70 last_modified::LastModified,
71 preference::Preference,
72 range::{ByteRangeSpec, Range},
73};
74
75#[derive(Debug, Default)]
77struct Writer {
78 buf: BytesMut,
79}
80
81impl Writer {
82 pub fn new() -> Writer {
84 Writer::default()
85 }
86
87 pub fn take(&mut self) -> Bytes {
89 self.buf.split().freeze()
90 }
91}
92
93impl fmt::Write for Writer {
94 #[inline]
95 fn write_str(&mut self, s: &str) -> fmt::Result {
96 self.buf.extend_from_slice(s.as_bytes());
97 Ok(())
98 }
99
100 #[inline]
101 fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> fmt::Result {
102 fmt::write(self, args)
103 }
104}