1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 17:52:56 +01:00

make some http re-exports more accessible (#2171)

This commit is contained in:
Rob Ede 2021-04-19 03:29:38 +01:00 committed by GitHub
parent b9dbc58e20
commit db97974dc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 66 additions and 20 deletions

View File

@ -1,6 +1,19 @@
# Changes # Changes
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
### Added
* Re-export `http` crate's `Error` type as `error::HttpError`. [#2171]
* Re-export `StatusCode`, `Method`, `Version` and `Uri` at the crate root. [#2171]
* Re-export `ContentEncoding` and `ConnectionType` at the crate root. [#2171]
### Changed
* `header` mod is now public. [#2171]
* `uri` mod is now public. [#2171]
### Removed
* Stop re-exporting `http` crate's `HeaderMap` types in addition to ours. [#2171]
[#2171]: https://github.com/actix/actix-web/pull/2171
## 3.0.0-beta.6 - 2021-04-17 ## 3.0.0-beta.6 - 2021-04-17

View File

@ -10,12 +10,13 @@ use std::{
use bytes::BytesMut; use bytes::BytesMut;
use derive_more::{Display, Error, From}; use derive_more::{Display, Error, From};
use http::uri::InvalidUri; use http::{header, uri::InvalidUri, StatusCode};
use http::{header, Error as HttpError, StatusCode};
use serde::de::value::Error as DeError; use serde::de::value::Error as DeError;
use crate::{body::Body, helpers::Writer, Response, ResponseBuilder}; use crate::{body::Body, helpers::Writer, Response, ResponseBuilder};
pub use http::Error as HttpError;
/// A specialized [`std::result::Result`] /// A specialized [`std::result::Result`]
/// for actix web operations /// for actix web operations
/// ///

View File

@ -1,9 +1,33 @@
//! Typed HTTP headers, pre-defined `HeaderName`s, traits for parsing and conversion, and other //! Pre-defined `HeaderName`s, traits for parsing and conversion, and other header utility methods.
//! header utility methods.
use percent_encoding::{AsciiSet, CONTROLS}; use percent_encoding::{AsciiSet, CONTROLS};
pub use http::header::*; // re-export from http except header map related items
pub use http::header::{
HeaderName, HeaderValue, InvalidHeaderName, InvalidHeaderValue, ToStrError,
};
// re-export const header names
pub use http::header::{
ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ACCEPT_RANGES,
ACCESS_CONTROL_ALLOW_CREDENTIALS, ACCESS_CONTROL_ALLOW_HEADERS,
ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN,
ACCESS_CONTROL_EXPOSE_HEADERS, ACCESS_CONTROL_MAX_AGE,
ACCESS_CONTROL_REQUEST_HEADERS, ACCESS_CONTROL_REQUEST_METHOD, AGE, ALLOW, ALT_SVC,
AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_DISPOSITION, CONTENT_ENCODING,
CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_RANGE,
CONTENT_SECURITY_POLICY, CONTENT_SECURITY_POLICY_REPORT_ONLY, CONTENT_TYPE, COOKIE,
DATE, DNT, ETAG, EXPECT, EXPIRES, FORWARDED, FROM, HOST, IF_MATCH,
IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_RANGE, IF_UNMODIFIED_SINCE, LAST_MODIFIED,
LINK, LOCATION, MAX_FORWARDS, ORIGIN, PRAGMA, PROXY_AUTHENTICATE,
PROXY_AUTHORIZATION, PUBLIC_KEY_PINS, PUBLIC_KEY_PINS_REPORT_ONLY, RANGE, REFERER,
REFERRER_POLICY, REFRESH, RETRY_AFTER, SEC_WEBSOCKET_ACCEPT,
SEC_WEBSOCKET_EXTENSIONS, SEC_WEBSOCKET_KEY, SEC_WEBSOCKET_PROTOCOL,
SEC_WEBSOCKET_VERSION, SERVER, SET_COOKIE, STRICT_TRANSPORT_SECURITY, TE, TRAILER,
TRANSFER_ENCODING, UPGRADE, UPGRADE_INSECURE_REQUESTS, USER_AGENT, VARY, VIA,
WARNING, WWW_AUTHENTICATE, X_CONTENT_TYPE_OPTIONS, X_DNS_PREFETCH_CONTROL,
X_FRAME_OPTIONS, X_XSS_PROTECTION,
};
use crate::error::ParseError; use crate::error::ParseError;
use crate::HttpMessage; use crate::HttpMessage;

View File

@ -35,7 +35,7 @@ mod config;
#[cfg(feature = "compress")] #[cfg(feature = "compress")]
pub mod encoding; pub mod encoding;
mod extensions; mod extensions;
mod header; pub mod header;
mod helpers; mod helpers;
mod http_message; mod http_message;
mod message; mod message;
@ -56,7 +56,9 @@ pub use self::builder::HttpServiceBuilder;
pub use self::config::{KeepAlive, ServiceConfig}; pub use self::config::{KeepAlive, ServiceConfig};
pub use self::error::{Error, ResponseError, Result}; pub use self::error::{Error, ResponseError, Result};
pub use self::extensions::Extensions; pub use self::extensions::Extensions;
pub use self::header::ContentEncoding;
pub use self::http_message::HttpMessage; pub use self::http_message::HttpMessage;
pub use self::message::ConnectionType;
pub use self::message::{Message, RequestHead, RequestHeadType, ResponseHead}; pub use self::message::{Message, RequestHead, RequestHeadType, ResponseHead};
pub use self::payload::{Payload, PayloadStream}; pub use self::payload::{Payload, PayloadStream};
pub use self::request::Request; pub use self::request::Request;
@ -64,6 +66,10 @@ pub use self::response::Response;
pub use self::response_builder::ResponseBuilder; pub use self::response_builder::ResponseBuilder;
pub use self::service::HttpService; pub use self::service::HttpService;
pub use ::http::{uri, uri::Uri};
pub use ::http::{Method, StatusCode, Version};
// TODO: deprecate this mish-mash of random items
pub mod http { pub mod http {
//! Various HTTP related types. //! Various HTTP related types.

View File

@ -1,12 +1,15 @@
use std::cell::{Ref, RefCell, RefMut}; use std::{
use std::net; cell::{Ref, RefCell, RefMut},
use std::rc::Rc; net,
rc::Rc,
};
use bitflags::bitflags; use bitflags::bitflags;
use crate::extensions::Extensions; use crate::{
use crate::header::HeaderMap; header::{self, HeaderMap},
use crate::http::{header, Method, StatusCode, Uri, Version}; Extensions, Method, StatusCode, Uri, Version,
};
/// Represents various types of connection /// Represents various types of connection
#[derive(Copy, Clone, PartialEq, Debug)] #[derive(Copy, Clone, PartialEq, Debug)]

View File

@ -14,12 +14,10 @@ use futures_core::Stream;
use crate::{ use crate::{
body::{Body, BodyStream, ResponseBody}, body::{Body, BodyStream, ResponseBody},
error::Error, error::{Error, HttpError},
extensions::Extensions, header::{self, IntoHeaderPair, IntoHeaderValue},
header::{IntoHeaderPair, IntoHeaderValue},
http::{header, Error as HttpError, StatusCode},
message::{BoxedResponseHead, ConnectionType, ResponseHead}, message::{BoxedResponseHead, ConnectionType, ResponseHead},
Response, Extensions, Response, StatusCode,
}; };
/// An HTTP response builder. /// An HTTP response builder.
@ -291,7 +289,7 @@ impl ResponseBuilder {
return None; return None;
} }
self.head.as_mut().map(|r| &mut **r) self.head.as_deref_mut()
} }
} }

View File

@ -4,7 +4,7 @@
## 0.1.0-beta.2 - 2021-04-17 ## 0.1.0-beta.2 - 2021-04-17
* * No significant changes from `0.1.0-beta.1`. * No significant changes from `0.1.0-beta.1`.
## 0.1.0-beta.1 - 2021-04-02 ## 0.1.0-beta.1 - 2021-04-02

View File

@ -9,6 +9,7 @@ use actix_http::{
}; };
use actix_router::{IntoPattern, Path, Resource, ResourceDef, Url}; use actix_router::{IntoPattern, Path, Resource, ResourceDef, Url};
use actix_service::{IntoServiceFactory, ServiceFactory}; use actix_service::{IntoServiceFactory, ServiceFactory};
#[cfg(feature = "cookies")]
use cookie::{Cookie, ParseError as CookieParseError}; use cookie::{Cookie, ParseError as CookieParseError};
use crate::dev::insert_slash; use crate::dev::insert_slash;