How to add custom header ( for example header ‘accept-encoding: gzip’ ) for downloadPage in Twisted ?
How to add custom header ( for example header ‘accept-encoding: gzip’ ) for downloadPage
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you look at the API documentation for
downloadPage, you’ll notice that it accepts*argsand**kwargs. It refers you toHTTPDownloaderfor documentation regarding those parameters.If you look at the API documentation for
HTTPDownloader, you’ll see that it accepts aheadersargument. This argument isn’t documented, but it’s what you’re looking for. Its value should be adictmapping header name to header value. So,should do what you want. Also, note the newer client API provided by Twisted, twisted.web.client.Agent. Since Twisted 11.1, this supports content encodings at a higher level, and has specific support for gzip.