How do I send a HEAD request manually using Firefox?

Paul Biggar picture Paul Biggar · Dec 29, 2009 · Viewed 32.6k times · Source

I'm debugging my webserver, and I'd like to manually send HEAD requests to some web pages. Is there a way to do this in Firefox? Some extension perhaps.

I want to use firefox so that it can be part of a normal session (ie cookies set, logged in, etc). So things like curl aren't perfect.

Answer

Christopher Tarquini picture Christopher Tarquini · Dec 29, 2009

Another possiblity is opening up firebug (or making this into a greasemonkey script) and using javascript to send your HEAD request.

// Added comments
 var xmlhttp = new XmlHttpRequest(); 
 xmlhttp.open("HEAD", "/test/this/page.php",true); // Make async HEAD request (must be a relative path to avoid cross-domain restrictions)
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) { // make sure the request is complete
   alert(xmlhttp.getAllResponseHeaders()) // display the headers
  }
 }
 xmlhttp.send(null); // send request

XmlHttpRequests inherit the cookies and current session (authentication from .htaccess etc).

Way to use this:

  • Use the javascript: url method
  • Use the Firebug console (http://getfirebug.com/) to execute javascript on the page
  • Create a greasemonkey script that executes HEAD requests and displays the result