Skip to content

Commit eb27387

Browse files
committed
Minor cleanups
1 parent 2f593f4 commit eb27387

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

src/adaptor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl RequestExt for ConduitRequest {
153153
let host = self
154154
.parts
155155
.headers()
156-
.get("host")
156+
.get(http::header::HOST)
157157
.map(|h| h.to_str().unwrap_or(""))
158158
.unwrap_or("");
159159
Host::Name(host)

src/lib.rs

-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(clippy::all, missing_debug_implementations, rust_2018_idioms)]
2-
#![allow(clippy::needless_doctest_main, clippy::unknown_clippy_lints)] // using the tokio::main attribute
32

43
//! A wrapper for integrating `hyper 0.13` with a `conduit 0.8` blocking application stack.
54
//!
@@ -57,17 +56,3 @@ pub use service::{BlockingHandler, Service};
5756

5857
type HyperResponse = hyper::Response<hyper::Body>;
5958
type ConduitResponse = conduit::Response<conduit::Body>;
60-
use crate::file_stream::FileStream;
61-
62-
/// Turns a `ConduitResponse` into a `HyperResponse`
63-
fn conduit_into_hyper(response: ConduitResponse) -> HyperResponse {
64-
use conduit::Body::*;
65-
66-
let (parts, body) = response.into_parts();
67-
let body = match body {
68-
Static(slice) => slice.into(),
69-
Owned(vec) => vec.into(),
70-
File(file) => FileStream::from_std(file).into_streamed_body(),
71-
};
72-
HyperResponse::from_parts(parts, body)
73-
}

src/service/blocking_handler.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::adaptor::{ConduitRequest, RequestInfo};
2+
use crate::file_stream::FileStream;
23
use crate::service::ServiceError;
3-
use crate::{conduit_into_hyper, HyperResponse};
4+
use crate::{ConduitResponse, HyperResponse};
45

56
use std::net::SocketAddr;
67
use std::sync::{
@@ -60,6 +61,19 @@ impl<H: Handler> BlockingHandler<H> {
6061
}
6162
}
6263

64+
/// Turns a `ConduitResponse` into a `HyperResponse`
65+
fn conduit_into_hyper(response: ConduitResponse) -> HyperResponse {
66+
use conduit::Body::*;
67+
68+
let (parts, body) = response.into_parts();
69+
let body = match body {
70+
Static(slice) => slice.into(),
71+
Owned(vec) => vec.into(),
72+
File(file) => FileStream::from_std(file).into_streamed_body(),
73+
};
74+
HyperResponse::from_parts(parts, body)
75+
}
76+
6377
/// Logs an error message and returns a generic status 500 response
6478
fn server_error_response(message: &str) -> HyperResponse {
6579
error!("Internal Server Error: {}", message);

0 commit comments

Comments
 (0)