config options for HTTP compression on tower+reqwest
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
44435f76fe
commit
f818c368c0
5 changed files with 93 additions and 17 deletions
|
@ -88,7 +88,7 @@ impl Client {
|
|||
None => env!("CARGO_PKG_VERSION").to_owned(),
|
||||
};
|
||||
|
||||
let builder = reqwest::Client::builder()
|
||||
let mut builder = reqwest::Client::builder()
|
||||
.hickory_dns(true)
|
||||
.timeout(Duration::from_secs(config.request_timeout))
|
||||
.connect_timeout(Duration::from_secs(config.request_conn_timeout))
|
||||
|
@ -97,6 +97,34 @@ impl Client {
|
|||
.user_agent("Conduwuit".to_owned() + "/" + &version)
|
||||
.redirect(redirect::Policy::limited(6));
|
||||
|
||||
#[cfg(feature = "gzip_compression")]
|
||||
{
|
||||
builder = if config.gzip_compression {
|
||||
builder.gzip(true)
|
||||
} else {
|
||||
builder.gzip(false).no_gzip()
|
||||
};
|
||||
};
|
||||
|
||||
#[cfg(feature = "brotli_compression")]
|
||||
{
|
||||
builder = if config.brotli_compression {
|
||||
builder.brotli(true)
|
||||
} else {
|
||||
builder.brotli(false).no_brotli()
|
||||
};
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "gzip_compression"))]
|
||||
{
|
||||
builder = builder.no_gzip();
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "brotli_compression"))]
|
||||
{
|
||||
builder = builder.no_brotli();
|
||||
}
|
||||
|
||||
if let Some(proxy) = config.proxy.to_proxy()? {
|
||||
Ok(builder.proxy(proxy))
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue