Skip to content

Commit

Permalink
Add HTTP/0.9 responses support
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep Mengual authored and seanmonstar committed Jan 7, 2022
1 parent 7388b67 commit 56ad99b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>,
http2_initial_connection_window_size: Option<u32>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 56ad99b

Please sign in to comment.