Parse raw HTTP Headers

Update: It’s 2019, so I have rewritten this answer for Python 3, following a confused comment from a programmer trying to use the code. The original Python 2 code is now down at the bottom of the answer. There are excellent tools in the Standard Library both for parsing RFC 821 headers, and also for parsing … Read more

How to specify HTTP expiration header? (ASP.NET MVC+IIS)

Found it: I need to specify client cache for static content (in web.config). <configuration> <system.webServer> <staticContent> <clientCache cacheControlCustom=”public” cacheControlMaxAge=”12:00:00″ cacheControlMode=”UseMaxAge” /> </staticContent> </system.webServer> </configuration> from http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache

Create a text file for download on-the-fly

No need to store it anywhere. Just output the content with the appropriate content type. <?php header(‘Content-type: text/plain’); ?>Hello, world. Add content-disposition if you wish to trigger a download prompt. header(‘Content-Disposition: attachment; filename=”default-filename.txt”‘);

Cross-Domain AJAX doesn’t send X-Requested-With header

If you are using jQuery to do your ajax request, it will not send the header X-Requested-With (HTTP_X_REQUESTED_WITH) = XMLHttpRequest, because it is cross domain. But there are 2 ways to fix this and send the header: Option 1) Manually set the header in the ajax call: $.ajax({ url: “http://your-url…”, headers: {‘X-Requested-With’: ‘XMLHttpRequest’} }); Option … Read more

Chrome browser is not sending if-modified-since header to server

After spending half a day on this yesterday, I tracked down what was causing the issue for me. So long as you have the Chrome object inspector/Client Debugger/Network monitor/Thing that pops up when you hit F12, Chrome will not send cache request headers. Period. (update: in newer versions of Chrome, there is a checkbox “Disable … Read more

Examine http response headers in IE8

You might be looking for Fiddler2 Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and “fiddle” with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language. … Read more