From b960b5827c844d32bb85ea560d0d9e0783c2aaf7 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 11 Oct 2018 20:15:10 -0700 Subject: [PATCH] export Uri --- src/h1/service.rs | 2 +- src/lib.rs | 5 +++-- src/request.rs | 13 ++++++++----- src/uri.rs | 6 +++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/h1/service.rs b/src/h1/service.rs index a7261df17..aa7a51733 100644 --- a/src/h1/service.rs +++ b/src/h1/service.rs @@ -22,7 +22,7 @@ pub struct H1Service { impl H1Service where - S: NewService, + S: NewService + Clone, S::Service: Clone, S::Error: Debug, { diff --git a/src/lib.rs b/src/lib.rs index 85bf9c2ff..5ce3ec39f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,7 +110,7 @@ mod json; mod payload; mod request; mod response; -mod uri; +pub mod uri; pub mod error; pub mod h1; @@ -148,10 +148,11 @@ pub mod http { //! Various HTTP related types // re-exports + pub use modhttp::header::{HeaderName, HeaderValue}; pub use modhttp::{Method, StatusCode, Version}; #[doc(hidden)] - pub use modhttp::{uri, Error, Extensions, HeaderMap, HttpTryFrom, Uri}; + pub use modhttp::{uri, Error, HeaderMap, HttpTryFrom, Uri}; pub use cookie::{Cookie, CookieBuilder}; diff --git a/src/request.rs b/src/request.rs index 82d8c22fa..ef28e3694 100644 --- a/src/request.rs +++ b/src/request.rs @@ -8,7 +8,7 @@ use http::{header, HeaderMap, Method, Uri, Version}; use extensions::Extensions; use httpmessage::HttpMessage; use payload::Payload; -use uri::Url as InnerUrl; +use uri::Url; bitflags! { pub(crate) struct MessageFlags: u8 { @@ -25,7 +25,7 @@ pub struct Request { pub(crate) struct InnerRequest { pub(crate) version: Version, pub(crate) method: Method, - pub(crate) url: InnerUrl, + pub(crate) url: Url, pub(crate) flags: Cell, pub(crate) headers: HeaderMap, pub(crate) extensions: RefCell, @@ -73,7 +73,7 @@ impl Request { inner: Rc::new(InnerRequest { pool, method: Method::GET, - url: InnerUrl::default(), + url: Url::default(), version: Version::HTTP_11, headers: HeaderMap::with_capacity(16), flags: Cell::new(MessageFlags::empty()), @@ -94,7 +94,7 @@ impl Request { } #[inline] - pub(crate) fn url(&self) -> &InnerUrl { + pub fn url(&self) -> &Url { &self.inner().url } @@ -162,7 +162,10 @@ impl Request { self.inner().method == Method::CONNECT } - pub(crate) fn clone(&self) -> Self { + #[doc(hidden)] + /// Note: this method should be called only as part of clone operation + /// of wrapper type. + pub fn clone_request(&self) -> Self { Request { inner: self.inner.clone(), } diff --git a/src/uri.rs b/src/uri.rs index 881cf20a8..6edd220ce 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -32,11 +32,11 @@ fn set_bit(array: &mut [u8], ch: u8) { } lazy_static! { - static ref DEFAULT_QUOTER: Quoter = { Quoter::new(b"@:", b"/+") }; + pub static ref DEFAULT_QUOTER: Quoter = { Quoter::new(b"@:", b"/+") }; } #[derive(Default, Clone, Debug)] -pub(crate) struct Url { +pub struct Url { uri: Uri, path: Option>, } @@ -61,7 +61,7 @@ impl Url { } } -pub(crate) struct Quoter { +pub struct Quoter { safe_table: [u8; 16], protected_table: [u8; 16], }