Skip to content

Commit

Permalink
feat(server): remove http1_ method prefixes from `server::conn::http2…
Browse files Browse the repository at this point in the history
…::Builder`

Refs: #3085
  • Loading branch information
Michael-J-Ward authored and seanmonstar committed Dec 28, 2022
1 parent 669df21 commit 48e70c6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions examples/http_proxy.rs
Expand Up @@ -31,8 +31,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

tokio::task::spawn(async move {
if let Err(err) = http1::Builder::new()
.http1_preserve_header_case(true)
.http1_title_case_headers(true)
.preserve_header_case(true)
.title_case_headers(true)
.serve_connection(stream, service_fn(proxy))
.with_upgrades()
.await
Expand Down
12 changes: 6 additions & 6 deletions src/server/conn/http1.rs
Expand Up @@ -224,15 +224,15 @@ impl Builder {
/// detects an EOF in the middle of a request.
///
/// Default is `false`.
pub fn http1_half_close(&mut self, val: bool) -> &mut Self {
pub fn half_close(&mut self, val: bool) -> &mut Self {
self.h1_half_close = val;
self
}

/// Enables or disables HTTP/1 keep-alive.
///
/// Default is true.
pub fn http1_keep_alive(&mut self, val: bool) -> &mut Self {
pub fn keep_alive(&mut self, val: bool) -> &mut Self {
self.h1_keep_alive = val;
self
}
Expand All @@ -243,7 +243,7 @@ impl Builder {
/// Note that this setting does not affect HTTP/2.
///
/// Default is false.
pub fn http1_title_case_headers(&mut self, enabled: bool) -> &mut Self {
pub fn title_case_headers(&mut self, enabled: bool) -> &mut Self {
self.h1_title_case_headers = enabled;
self
}
Expand All @@ -261,7 +261,7 @@ impl Builder {
/// Note that this setting does not affect HTTP/2.
///
/// Default is false.
pub fn http1_preserve_header_case(&mut self, enabled: bool) -> &mut Self {
pub fn preserve_header_case(&mut self, enabled: bool) -> &mut Self {
self.h1_preserve_header_case = enabled;
self
}
Expand All @@ -270,7 +270,7 @@ impl Builder {
/// transmit the entire header within this time, the connection is closed.
///
/// Default is None.
pub fn http1_header_read_timeout(&mut self, read_timeout: Duration) -> &mut Self {
pub fn header_read_timeout(&mut self, read_timeout: Duration) -> &mut Self {
self.h1_header_read_timeout = Some(read_timeout);
self
}
Expand All @@ -287,7 +287,7 @@ impl Builder {
///
/// Default is `auto`. In this mode hyper will try to guess which
/// mode to use
pub fn http1_writev(&mut self, val: bool) -> &mut Self {
pub fn writev(&mut self, val: bool) -> &mut Self {
self.h1_writev = Some(val);
self
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/conn/mod.rs
Expand Up @@ -30,7 +30,7 @@
//! let (tcp_stream, _) = tcp_listener.accept().await?;
//! tokio::task::spawn(async move {
//! if let Err(http_err) = http1::Builder::new()
//! .http1_keep_alive(true)
//! .keep_alive(true)
//! .serve_connection(tcp_stream, service_fn(hello))
//! .await {
//! eprintln!("Error while serving HTTP connection: {}", http_err);
Expand Down
10 changes: 5 additions & 5 deletions tests/server.rs
Expand Up @@ -1247,7 +1247,7 @@ async fn http1_allow_half_close() {

let (socket, _) = listener.accept().await.unwrap();
http1::Builder::new()
.http1_half_close(true)
.half_close(true)
.serve_connection(
socket,
service_fn(|_| {
Expand All @@ -1274,7 +1274,7 @@ async fn disconnect_after_reading_request_before_responding() {

let (socket, _) = listener.accept().await.unwrap();
http1::Builder::new()
.http1_half_close(false)
.half_close(false)
.serve_connection(
socket,
service_fn(|_| {
Expand Down Expand Up @@ -1370,7 +1370,7 @@ async fn header_read_timeout_slow_writes() {
let (socket, _) = listener.accept().await.unwrap();
let conn = http1::Builder::new()
.timer(TokioTimer)
.http1_header_read_timeout(Duration::from_secs(5))
.header_read_timeout(Duration::from_secs(5))
.serve_connection(
socket,
service_fn(|_| {
Expand Down Expand Up @@ -1445,7 +1445,7 @@ async fn header_read_timeout_slow_writes_multiple_requests() {
let (socket, _) = listener.accept().await.unwrap();
let conn = http1::Builder::new()
.timer(TokioTimer)
.http1_header_read_timeout(Duration::from_secs(5))
.header_read_timeout(Duration::from_secs(5))
.serve_connection(
socket,
service_fn(|_| {
Expand Down Expand Up @@ -2839,7 +2839,7 @@ impl ServeOptions {
.serve_connection(stream, service).await.unwrap();
} else {
http1::Builder::new()
.http1_keep_alive(_options.keep_alive)
.keep_alive(_options.keep_alive)
.pipeline_flush(_options.pipeline)
.serve_connection(stream, service).await.unwrap();
}
Expand Down

0 comments on commit 48e70c6

Please sign in to comment.