mirror of https://github.com/fafhrd91/actix-web
move some shared headers to -web
This commit is contained in:
parent
aa6deb1909
commit
d61ee3382b
|
@ -1,9 +1,6 @@
|
||||||
//! Typed HTTP headers, pre-defined `HeaderName`s, traits for parsing and conversion, and other
|
//! Typed HTTP headers, pre-defined `HeaderName`s, traits for parsing and conversion, and other
|
||||||
//! header utility methods.
|
//! header utility methods.
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
|
||||||
use percent_encoding::{AsciiSet, CONTROLS};
|
use percent_encoding::{AsciiSet, CONTROLS};
|
||||||
|
|
||||||
pub use http::header::*;
|
pub use http::header::*;
|
||||||
|
@ -39,35 +36,6 @@ pub trait Header: IntoHeaderValue {
|
||||||
fn parse<T: HttpMessage>(msg: &T) -> Result<Self, ParseError>;
|
fn parse<T: HttpMessage>(msg: &T) -> Result<Self, ParseError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
pub 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert `http::HeaderMap` to our `HeaderMap`.
|
/// Convert `http::HeaderMap` to our `HeaderMap`.
|
||||||
impl From<http::HeaderMap> for HeaderMap {
|
impl From<http::HeaderMap> for HeaderMap {
|
||||||
fn from(mut map: http::HeaderMap) -> HeaderMap {
|
fn from(mut map: http::HeaderMap) -> HeaderMap {
|
||||||
|
|
|
@ -2,16 +2,12 @@
|
||||||
|
|
||||||
mod charset;
|
mod charset;
|
||||||
mod content_encoding;
|
mod content_encoding;
|
||||||
mod encoding;
|
|
||||||
mod entity;
|
|
||||||
mod extended;
|
mod extended;
|
||||||
mod httpdate;
|
|
||||||
mod quality_item;
|
mod quality_item;
|
||||||
|
mod httpdate;
|
||||||
|
|
||||||
pub use self::charset::Charset;
|
pub use self::charset::Charset;
|
||||||
pub use self::content_encoding::ContentEncoding;
|
pub use self::content_encoding::ContentEncoding;
|
||||||
pub use self::encoding::Encoding;
|
|
||||||
pub use self::entity::EntityTag;
|
|
||||||
pub use self::extended::{parse_extended_value, ExtendedValue};
|
pub use self::extended::{parse_extended_value, ExtendedValue};
|
||||||
pub use self::httpdate::HttpDate;
|
pub use self::httpdate::HttpDate;
|
||||||
pub use self::quality_item::{q, qitem, Quality, QualityItem};
|
pub use self::quality_item::{q, qitem, Quality, QualityItem};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::fmt::{self, Display, Write};
|
use std::fmt::{self, Display, Write};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::header::{HeaderValue, IntoHeaderValue, InvalidHeaderValue, Writer};
|
use super::{HeaderValue, IntoHeaderValue, InvalidHeaderValue, Writer};
|
||||||
|
|
||||||
/// check that each char in the slice is either:
|
/// check that each char in the slice is either:
|
||||||
/// 1. `%x21`, or
|
/// 1. `%x21`, or
|
|
@ -7,6 +7,9 @@
|
||||||
//! is used, such as `ContentType(pub Mime)`.
|
//! is used, such as `ContentType(pub Mime)`.
|
||||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||||
|
|
||||||
|
use std::fmt;
|
||||||
|
use bytes::{BytesMut, Bytes};
|
||||||
|
|
||||||
pub use actix_http::http::header::*;
|
pub use actix_http::http::header::*;
|
||||||
pub use self::accept_charset::AcceptCharset;
|
pub use self::accept_charset::AcceptCharset;
|
||||||
//pub use self::accept_encoding::AcceptEncoding;
|
//pub use self::accept_encoding::AcceptEncoding;
|
||||||
|
@ -29,9 +32,40 @@ pub use self::if_none_match::IfNoneMatch;
|
||||||
pub use self::if_range::IfRange;
|
pub use self::if_range::IfRange;
|
||||||
pub use self::if_unmodified_since::IfUnmodifiedSince;
|
pub use self::if_unmodified_since::IfUnmodifiedSince;
|
||||||
pub use self::last_modified::LastModified;
|
pub use self::last_modified::LastModified;
|
||||||
|
pub use self::encoding::Encoding;
|
||||||
|
pub use self::entity::EntityTag;
|
||||||
//pub use self::range::{Range, ByteRangeSpec};
|
//pub use self::range::{Range, ByteRangeSpec};
|
||||||
pub(crate) use actix_http::http::header::{fmt_comma_delimited, from_comma_delimited, from_one_raw_str};
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! __hyper__deref {
|
macro_rules! __hyper__deref {
|
||||||
|
@ -353,3 +387,5 @@ mod if_none_match;
|
||||||
mod if_range;
|
mod if_range;
|
||||||
mod if_unmodified_since;
|
mod if_unmodified_since;
|
||||||
mod last_modified;
|
mod last_modified;
|
||||||
|
mod encoding;
|
||||||
|
mod entity;
|
||||||
|
|
Loading…
Reference in New Issue