From da90b45b672f6bbfc58a4d71a77401c9a219a428 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Fri, 9 Aug 2019 22:38:46 +0200 Subject: [PATCH] Add optional accept header --- backend/src/main.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/src/main.rs b/backend/src/main.rs index 8763059..d8f4f4e 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -97,11 +97,16 @@ fn redirect( cache.clear(); } } + let req = client + .get(&T::api_url(&data)) + .header(header::USER_AGENT, statics::USER_AGENT.as_str()); + let req = if let Some(accept) = T::api_accept() { + req.header(header::ACCEPT, accept) + } else { + req + }; Box::new( - client - .get(&T::api_url(&data)) - .header(header::USER_AGENT, statics::USER_AGENT.as_str()) - .send() + req.send() .from_err() .and_then(move |response| T::request_head(response, data, client, Arc::clone(&cache))), )