1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-11 09:49:29 +00:00
actix-web/src/http/header/mod.rs

92 lines
2.4 KiB
Rust
Raw Normal View History

2019-02-07 21:24:24 +00:00
//! A Collection of Header implementations for common HTTP Headers.
//!
//! ## Mime
//!
2021-04-15 21:05:06 +00:00
//! Several header fields use MIME values for their contents. Keeping with the strongly-typed theme,
//! the [mime] crate is used in such headers as [`ContentType`] and [`Accept`].
2019-02-07 21:24:24 +00:00
2021-04-15 21:05:06 +00:00
use bytes::{Bytes, BytesMut};
use std::fmt;
2019-02-07 21:24:24 +00:00
pub use self::accept_charset::AcceptCharset;
2021-04-15 21:05:06 +00:00
pub use actix_http::http::header::*;
2019-02-07 21:24:24 +00:00
//pub use self::accept_encoding::AcceptEncoding;
pub use self::accept::Accept;
pub use self::accept_language::AcceptLanguage;
2019-02-07 21:24:24 +00:00
pub use self::allow::Allow;
pub use self::cache_control::{CacheControl, CacheDirective};
2021-04-15 21:05:06 +00:00
pub use self::content_disposition::{ContentDisposition, DispositionParam, DispositionType};
2019-02-07 21:24:24 +00:00
pub use self::content_language::ContentLanguage;
pub use self::content_range::{ContentRange, ContentRangeSpec};
pub use self::content_type::ContentType;
pub use self::date::Date;
2021-04-15 21:05:06 +00:00
pub use self::encoding::Encoding;
pub use self::entity::EntityTag;
2019-02-07 21:24:24 +00:00
pub use self::etag::ETag;
pub use self::expires::Expires;
pub use self::if_match::IfMatch;
pub use self::if_modified_since::IfModifiedSince;
pub use self::if_none_match::IfNoneMatch;
pub use self::if_range::IfRange;
pub use self::if_unmodified_since::IfUnmodifiedSince;
pub use self::last_modified::LastModified;
//pub use self::range::{Range, ByteRangeSpec};
2021-04-15 21:05:06 +00:00
pub(crate) use actix_http::http::header::{
fmt_comma_delimited, from_comma_delimited, from_one_raw_str,
};
#[derive(Debug, Default)]
struct Writer {
buf: BytesMut,
}
impl Writer {
pub fn new() -> Writer {
Writer::default()
}
pub fn take(&mut self) -> Bytes {
self.buf.split().freeze()
}
}
impl fmt::Write for Writer {
#[inline]
fn write_str(&mut self, s: &str) -> fmt::Result {
self.buf.extend_from_slice(s.as_bytes());
Ok(())
}
#[inline]
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> fmt::Result {
fmt::write(self, args)
}
}
2019-02-07 21:24:24 +00:00
mod accept_charset;
2021-01-15 02:11:10 +00:00
// mod accept_encoding;
2019-02-07 21:24:24 +00:00
mod accept;
mod accept_language;
2019-02-07 21:24:24 +00:00
mod allow;
mod cache_control;
mod content_disposition;
mod content_language;
mod content_range;
mod content_type;
mod date;
2021-04-15 21:05:06 +00:00
mod encoding;
mod entity;
2019-02-07 21:24:24 +00:00
mod etag;
mod expires;
mod if_match;
mod if_modified_since;
mod if_none_match;
mod if_range;
mod if_unmodified_since;
mod last_modified;
2021-06-25 11:25:50 +00:00
2021-04-15 21:05:06 +00:00
mod macros;
2021-06-25 11:25:50 +00:00
#[cfg(test)]
pub(crate) use macros::common_header_test;
pub(crate) use macros::{common_header, common_header_deref, common_header_test_module};