mirror of
https://github.com/searxng/searxng.git
synced 2024-11-25 12:21:00 +00:00
[enh] useragent forwarding
This commit is contained in:
parent
aa3d63159e
commit
492e0b74c0
1 changed files with 6 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue