Wednesday 18 June 2014

Print HTTP Response Header: Python

When you make an HTTP request to retrieve a webpage you get an HTTP response back. This response includes the usual response body that we see in the web browsers and an HTTP header, which is usually not shown in the web browsers. But this HTTP header may give some useful insight about the web page, web server, cookies, etc. 


The following simple python script prints the HTTP response header for the URL passed as a command line parameter:



Output of the above script, with http://python.org as the command line parameter,  is shown below:

No comments:

Post a Comment