Remove Default HTTP headers in async http client

966 views
Skip to first unread message

Marios Kourtesis

unread,
Feb 6, 2015, 4:07:37 PM2/6/15
to python-...@googlegroups.com
Hello,
Is the any way to completely remove the default HTTP headers in tornado AsyncHTTPclient? I am talking about User-Agent, Accept, Accept Encoding and Host.
I am working on a security project and I need to create HTTP requests that are not following the HTTP standards.
AFAIK curl support that (http://curl.haxx.se/mail/archive-2008-07/0169.html).

King Regards
Marios


aliane abdelouahab

unread,
Feb 6, 2015, 7:31:18 PM2/6/15
to python-...@googlegroups.com
i think you can change their names in the code (the direct way), or change them when you instanciate HTTPRequest

Marios Kourtesis

unread,
Feb 7, 2015, 9:31:25 AM2/7/15
to python-...@googlegroups.com
Hello Aliane,
Thank you for you reply,
I tried something similar and it did not worked! Can you please provide me an example?


--
You received this message because you are subscribed to a topic in the Google Groups "Tornado Web Server" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-tornado/3TbO6mR0qiQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ben Darnell

unread,
Feb 7, 2015, 11:14:51 AM2/7/15
to Tornado Mailing List

It sounds like you’re using curl_httpclient, since simple_httpclient doesn’t set as many headers automatically. In curl_httpclient, you can turn off any of the automatic headers by setting them to an empty string: headers={'User-Agent': '', 'Accept': '', 'Accept-Encoding': '', 'Host': ''}.

In simple_httpclient you can turn off the Accept-Encoding header by passing decompress_response=False. The other headers that are set automatically (Host and Connection) are necessary for the operation of the protocol so we do not let you send a request without them (you can set Host to a different value, but you can’t turn it off).

Also consider the pattern used in some of Tornado’s own tests, in which we construct a request by hand and then use HTTP1Connection to read the response. This may be better for you if you need to generate invalid HTTP messages:
https://github.com/tornadoweb/tornado/blob/fff09e9028bed0cf1d3f3e711ff4e15d4a2440a2/tornado/test/httpserver_test.py#L213

-Ben


--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.

Marios Kourtesis

unread,
Feb 9, 2015, 9:53:26 AM2/9/15
to python-...@googlegroups.com
Hello Ben,
Thank you for your reply! This is exactly what I was looking for!
Is there any way or hack that I can use raw_fetch in the curl or simple httpclient?

Kind Regads
Marios

--
You received this message because you are subscribed to a topic in the Google Groups "Tornado Web Server" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-tornado/3TbO6mR0qiQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-tornad...@googlegroups.com.

Ben Darnell

unread,
Feb 9, 2015, 12:02:47 PM2/9/15
to Tornado Mailing List
On Mon, Feb 9, 2015 at 9:53 AM, Marios Kourtesis <marios.k...@gmail.com> wrote:
Hello Ben,
Thank you for your reply! This is exactly what I was looking for!
Is there any way or hack that I can use raw_fetch in the curl or simple httpclient?

Not directly. You'll need to copy the code (for raw_fetch and the helper read_stream_body), and edit raw_fetch to remove its dependencies on the testing framework. read_stream_body uses the same parsing code as simple_httpclient; there is no way to do the same with curl.

-Ben
Reply all
Reply to author
Forward
0 new messages