From 492e0b74c026d7750fb0203ee941eff0eeda8f0b Mon Sep 17 00:00:00 2001 From: asciimoo Date: Mon, 14 Oct 2013 23:52:58 +0200 Subject: [PATCH] [enh] useragent forwarding --- searx/webapp.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/searx/webapp.py b/searx/webapp.py index 7c859d5d4..7af697275 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -38,18 +38,21 @@ def index(): query = request.form['q'] requests = [] results = [] + user_agent = request.headers.get('User-Agent', '') for engine in engines: - request_params = engine.request(query, default_request_params()) + headers = default_request_params() + headers['User-Agent'] = user_agent + request_params = engine.request(query, headers) callback = make_callback(results, engine.response) if request_params['method'] == 'GET': req = grequests.get(request_params['url'] - ,headers=request_params['headers'] + ,headers=headers ,hooks=dict(response=callback) ) else: req = grequests.post(request_params['url'] ,data=request_params['data'] - ,headers=request_params['headers'] + ,headers=headers ,hooks=dict(response=callback) ) requests.append(req)