Add optional accept header

This commit is contained in:
Valentin Brandl 2019-08-09 22:38:46 +02:00
parent b9dc926978
commit da90b45b67
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D

View File

@ -97,11 +97,16 @@ fn redirect<T: Service>(
cache.clear(); cache.clear();
} }
} }
Box::new( let req = client
client
.get(&T::api_url(&data)) .get(&T::api_url(&data))
.header(header::USER_AGENT, statics::USER_AGENT.as_str()) .header(header::USER_AGENT, statics::USER_AGENT.as_str());
.send() let req = if let Some(accept) = T::api_accept() {
req.header(header::ACCEPT, accept)
} else {
req
};
Box::new(
req.send()
.from_err() .from_err()
.and_then(move |response| T::request_head(response, data, client, Arc::clone(&cache))), .and_then(move |response| T::request_head(response, data, client, Arc::clone(&cache))),
) )