Skip to content

Commit d95b421

Browse files
committed
exposed some internal functions and structures to the public API
1 parent 2383cf2 commit d95b421

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

src/client/decode.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const CR: u8 = b'\r';
1616
const LF: u8 = b'\n';
1717

1818
/// Decode an HTTP response on the client.
19-
#[doc(hidden)]
2019
pub async fn decode<R>(reader: R) -> http_types::Result<Response>
2120
where
2221
R: Read + Unpin + Send + Sync + 'static,

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ const MAX_HEAD_LENGTH: usize = 8 * 1024;
106106

107107
mod chunked;
108108
mod date;
109-
mod server;
109+
pub mod server;
110110

111-
#[doc(hidden)]
112111
pub mod client;
113112

114113
pub use client::connect;

src/server/decode.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const LF: u8 = b'\n';
1717
const HTTP_1_1_VERSION: u8 = 1;
1818

1919
/// Decode an HTTP request on the server.
20-
pub(crate) async fn decode<IO>(mut io: IO) -> http_types::Result<Option<Request>>
20+
pub async fn decode<IO>(mut io: IO) -> http_types::Result<Option<Request>>
2121
where
2222
IO: Read + Write + Clone + Send + Sync + Unpin + 'static,
2323
{
@@ -116,13 +116,17 @@ fn set_url_and_port_from_host_header(req: &mut Request) -> http_types::Result<()
116116
.ok_or_else(|| format_err!("Mandatory Host header missing"))? // https://tools.ietf.org/html/rfc7230#section-5.4
117117
.to_string();
118118

119-
if let Some(colon) = host.find(":") {
120-
req.url_mut().set_host(Some(&host[0..colon]))?;
121-
req.url_mut()
122-
.set_port(host[colon + 1..].parse().ok())
123-
.unwrap();
124-
} else {
125-
req.url_mut().set_host(Some(&host))?;
119+
if !req.url().cannot_be_a_base() {
120+
if let Some(colon) = host.find(":") {
121+
println!("AAAA");
122+
req.url_mut().set_host(Some(&host[0..colon]))?;
123+
println!("AAAA");
124+
req.url_mut()
125+
.set_port(host[colon + 1..].parse().ok())
126+
.unwrap();
127+
} else {
128+
req.url_mut().set_host(Some(&host))?;
129+
}
126130
}
127131

128132
Ok(())

src/server/encode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::date::fmt_http_date;
1515
///
1616
/// This is returned from [`encode`].
1717
#[derive(Debug)]
18-
pub(crate) struct Encoder {
18+
pub struct Encoder {
1919
/// The current level of recursion the encoder is in.
2020
depth: u16,
2121
/// HTTP headers to be sent.
@@ -69,7 +69,7 @@ impl Read for Encoder {
6969

7070
impl Encoder {
7171
/// Create a new instance of Encoder.
72-
pub(crate) fn new(res: Response) -> Self {
72+
pub fn new(res: Response) -> Self {
7373
Self {
7474
res,
7575
depth: 0,

src/server/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use http_types::{Request, Response};
1010
mod decode;
1111
mod encode;
1212

13-
use decode::decode;
14-
use encode::Encoder;
13+
pub use decode::decode;
14+
pub use encode::Encoder;
1515

1616
/// Configure the server.
1717
#[derive(Debug, Clone)]

0 commit comments

Comments
 (0)