tornadoweb / tornadoweb/tornado
AsyncHTTPClient.configure doesnt seem to pass headers down to instances
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 22.2k
- Forks
- 5.6k
- Avg merge
- 3h 42m
- Merged PRs (30d)
- 16
Description
Version 6.0.4
Mac Catalina 10.15.4
When I use httpclient.AsyncHTTPClient.configure to set default headers they dont seem to be passed down to instances of AsyncHTTPClient in later uses. The arg validate_cert is passed on to instances but the headers dont seem to be. The docs have me believing this should be working.
example code
import json
from tornado import ioloop, web, locks, httputil, httpclient
class Test(web.RequestHandler):
async def get(self):
try:
resp = await httpclient.AsyncHTTPClient().fetch('https://www.google.com')
print(resp.request.headers)
except httpclient.HTTPError as e:
print(e)
class TornadoApp(web.Application):
def __init__(self):
handlers = [
(r"/test", Test)
]
settings = dict(
debug=True
)
httpclient.AsyncHTTPClient.configure(None, defaults=dict(
headers=httputil.HTTPHeaders({"test_header": "test_value"})
))
super(TornadoApp, self).__init__(handlers, **settings)
async def main():
""" Main entry point for the tornado web server """
tornado_app = TornadoApp()
tornado_app.listen(8881)
await locks.Event().wait()
if __name__ == '__main__':
ioloop.IOLoop.current().run_sync(main)
The headers printed here are missing the 'test_header' header
Connection: close
Host: www.google.com
Accept-Encoding: gzip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at AsyncHTTPClient.configure and trace how its defaults are applied when a later AsyncHTTPClient instance is created. Reproduce the example with the configured test_header, then verify that the resulting request headers include it while existing defaults such as validate_cert continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100