- commit
- 9b700e8b4ef1200d842df83e04b69d38b4e33f3d
- parent
- ed6e76a3989e040c937580b4659cf779f67ad4ca
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2018-08-17 17:47
fix aiohttp usage
Diffstat
| M | jsonproxy/__init__.py | 9 | ++++----- |
1 files changed, 4 insertions, 5 deletions
diff --git a/jsonproxy/__init__.py b/jsonproxy/__init__.py
@@ -67,8 +67,8 @@ async def _request(method, url): 67 67 raise aiohttp.web_exceptions.HTTPNotFound 68 68 response.raise_for_status() 69 69 # get response before closing the connection70 -1 await response.read()71 -1 return response-1 70 body = await response.read() -1 71 return body, response.status 72 72 73 73 74 74 async def handle(request): @@ -83,12 +83,11 @@ async def handle(request): 83 83 if request.query_string: 84 84 url += '?' + request.query_string 85 8586 -1 remote = await _request(request.method, url)87 -1 body = await remote.read()-1 86 body, status = await _request(request.method, url) 88 87 89 88 if 'fields' in config: 90 89 data = scrape(url, body, config)91 -1 response = web.json_response(data, status=remote.status)-1 90 response = web.json_response(data, status=status) 92 91 93 92 if CONFIG.get('ALLOW_CORS', False): 94 93 response.headers['Access-Control-Allow-Origin'] = '*'