From 56ad99bebbc7052ba2010434e2b5dbafd35d7152 Mon Sep 17 00:00:00 2001 From: Josep Mengual Date: Mon, 20 Dec 2021 22:48:50 +0100 Subject: [PATCH] Add HTTP/0.9 responses support --- Cargo.toml | 2 +- src/async_impl/client.rs | 12 ++++++++++++ src/blocking/client.rs | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d5f82e8..2182aa4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,7 +95,7 @@ encoding_rs = "0.8" futures-core = { version = "0.3.0", default-features = false } futures-util = { version = "0.3.0", default-features = false } http-body = "0.4.0" -hyper = { version = "0.14", default-features = false, features = ["tcp", "http1", "http2", "client", "runtime"] } +hyper = { version = "0.14.5", default-features = false, features = ["tcp", "http1", "http2", "client", "runtime"] } h2 = "0.3.10" lazy_static = "1.4" log = "0.4" diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index 43772ae..19438d9 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -103,6 +103,7 @@ struct Config { #[cfg(feature = "__tls")] tls: TlsBackend, http_version_pref: HttpVersionPref, + http09_responses: bool, http1_title_case_headers: bool, http2_initial_stream_window_size: Option, http2_initial_connection_window_size: Option, @@ -166,6 +167,7 @@ impl ClientBuilder { #[cfg(feature = "__tls")] tls: TlsBackend::default(), http_version_pref: HttpVersionPref::All, + http09_responses: false, http1_title_case_headers: false, http2_initial_stream_window_size: None, http2_initial_connection_window_size: None, @@ -458,6 +460,10 @@ impl ClientBuilder { builder.pool_max_idle_per_host(config.pool_max_idle_per_host); connector.set_keepalive(config.tcp_keepalive); + if config.http09_responses { + builder.http09_responses(true); + } + if config.http1_title_case_headers { builder.http1_title_case_headers(true); } @@ -842,6 +848,12 @@ impl ClientBuilder { self } + /// Allow HTTP/0.9 responses + pub fn http09_responses(mut self) -> ClientBuilder { + self.config.http09_responses = true; + self + } + /// Only use HTTP/2. pub fn http2_prior_knowledge(mut self) -> ClientBuilder { self.config.http_version_pref = HttpVersionPref::Http2; diff --git a/src/blocking/client.rs b/src/blocking/client.rs index 8da4251..95bcf17 100644 --- a/src/blocking/client.rs +++ b/src/blocking/client.rs @@ -412,6 +412,11 @@ impl ClientBuilder { self.with_inner(|inner| inner.http1_only()) } + /// Allow HTTP/0.9 responses + pub fn http09_responses(self) -> ClientBuilder { + self.with_inner(|inner| inner.http09_responses()) + } + /// Only use HTTP/2. pub fn http2_prior_knowledge(self) -> ClientBuilder { self.with_inner(|inner| inner.http2_prior_knowledge())