Skip to content

Commit

Permalink
Enable brotli for blocking (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
fiag committed Nov 20, 2020
1 parent 23aaa0b commit 0bae133
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,25 @@ impl ClientBuilder {
self.with_inner(|inner| inner.gzip(enable))
}

/// Enable auto brotli decompression by checking the `Content-Encoding` response header.
///
/// If auto brotli decompression is turned on:
///
/// - When sending a request and if the request's headers do not already contain
/// an `Accept-Encoding` **and** `Range` values, the `Accept-Encoding` header is set to `br`.
/// The request body is **not** automatically compressed.
/// - When receiving a response, if it's headers contain a `Content-Encoding` value that
/// equals to `br`, both values `Content-Encoding` and `Content-Length` are removed from the
/// headers' set. The response body is automatically decompressed.
///
/// If the `brotli` feature is turned on, the default option is enabled.
///
/// # Optional
///
/// This requires the optional `brotli` feature to be enabled
#[cfg(feature = "brotli")]
pub fn brotli(self, enable: bool) -> ClientBuilder { self.with_inner(|inner| inner.brotli(enable)) }

/// Disable auto response body gzip decompression.
///
/// This method exists even if the optional `gzip` feature is not enabled.
Expand All @@ -215,6 +234,13 @@ impl ClientBuilder {
self.with_inner(|inner| inner.no_gzip())
}

/// Disable auto response body brotli decompression.
///
/// This method exists even if the optional `brotli` feature is not enabled.
/// This can be used to ensure a `Client` doesn't use brotli decompression
/// even if another dependency were to enable the optional `brotli` feature.
pub fn no_brotli(self) -> ClientBuilder { self.with_inner(|inner| inner.no_brotli()) }

// Redirect options

/// Set a `redirect::Policy` for this client.
Expand Down

0 comments on commit 0bae133

Please sign in to comment.