Make gzip an optional feature (default off)
This commit is contained in:
		| @@ -97,7 +97,7 @@ impl ClientBuilder { | ||||
|  | ||||
|         ClientBuilder { | ||||
|             config: Config { | ||||
|                 gzip: true, | ||||
|                 gzip: cfg!(feature = "gzip"), | ||||
|                 headers, | ||||
|                 #[cfg(feature = "default-tls")] | ||||
|                 hostname_verification: true, | ||||
| @@ -312,22 +312,45 @@ impl ClientBuilder { | ||||
|         self | ||||
|     } | ||||
|  | ||||
|     /// Enable auto gzip decompression by checking the ContentEncoding response header. | ||||
|     /// Enable auto gzip decompression by checking the `Content-Encoding` response header. | ||||
|     /// | ||||
|     /// If auto gzip decompresson 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 `gzip`. | ||||
|     ///   The body is **not** automatically compressed. | ||||
|     ///   The request body is **not** automatically compressed. | ||||
|     /// - When receiving a response, if it's headers contain a `Content-Encoding` value that | ||||
|     ///   equals to `gzip`, both values `Content-Encoding` and `Content-Length` are removed from the | ||||
|     ///   headers' set. The body is automatically decompressed. | ||||
|     ///   headers' set. The response body is automatically decompressed. | ||||
|     /// | ||||
|     /// Default is enabled. | ||||
|     /// If the `gzip` feature is turned on, the default option is enabled. | ||||
|     /// | ||||
|     /// # Optional | ||||
|     /// | ||||
|     /// This requires the optional `gzip` feature to be enabled | ||||
|     #[cfg(feature = "gzip")] | ||||
|     pub fn gzip(mut self, enable: bool) -> ClientBuilder { | ||||
|         self.config.gzip = enable; | ||||
|         self | ||||
|     } | ||||
|  | ||||
|     /// Disable auto response body gzip decompression. | ||||
|     /// | ||||
|     /// This method exists even if the optional `gzip` feature is not enabled. | ||||
|     /// This can be used to ensure a `Client` doesn't use gzip decompression | ||||
|     /// even if another dependency were to enable the optional `gzip` feature. | ||||
|     pub fn no_gzip(self) -> ClientBuilder { | ||||
|         #[cfg(feature = "gzip")] | ||||
|         { | ||||
|             self.gzip(false) | ||||
|         } | ||||
|  | ||||
|         #[cfg(not(feature = "gzip"))] | ||||
|         { | ||||
|             self | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /// Add a `Proxy` to the list of proxies the `Client` will use. | ||||
|     pub fn proxy(mut self, proxy: Proxy) -> ClientBuilder { | ||||
|         self.config.proxies.push(proxy); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user