views:

777

answers:

5

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.

+1  A: 

I don't know of any plugin but this page might be of some use to you

http://www.askapache.com/online-tools/http-headers-tool

Chris T
That is useful. Doesn't work on localhost though. The reason I was looking for a firefox plugin was so that I could be logged in normally etc, and would get my cookies and such right.
Paul Biggar
+1  A: 

I believe that you can send head requests with Fiddler http://www.fiddler2.com/Fiddler2/version.asp

This seems to be a solution that works in firefox as an addon, called Modify Headers https://addons.mozilla.org/en-US/firefox/addon/967

Aaron M
As far as I can tell, that would work. I don't have a Windows box to hand though.
Paul Biggar
Fiddler works for this (and is awesome), but only works on Windows.
Bert Lamb
+4  A: 

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
Chris T
If you make it so the greasemonkey script places a small div at the top of the page with a GUI such as: [textbox for url] [Send Request]. You could even re-use this for other projects and even release it
Chris T
Nice answer. I guess if I can't find a simpler method, this ain't so bad.
Paul Biggar
I'm getting this error: "XmlHttpRequest is not defined", any ideas why?
J. Pablo Fernández
Try XMLHttpRequest instead or use var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new window.ActiveXObject("Microsoft.XMLHTTP");
Chris T
+1  A: 

Live HTTP Headers can send arbitrary HTTP requests using its replay function. Though it's a bit fiddly. And as it's a HEAD request, there'll be no output to see locally (it's normally displayed in the browser window).

First you need to open up the Live HTTP Headers (LHH) window, do your request from the browser using GET, then select that request in the LHH window and choose Replay.... Then, in the window that pops up, change GET to HEAD and fiddle with the headers if you like.

Pressing Replay will make the request.

Christopher
Works for me :)
Paul Biggar
I only saw an option for POST or GET (not HEAD) using Live HTTP Headers on FF 3.6 on windows. So if this used to work, it doesn't now :(
Bert Lamb
Thanks for the downvote. While there's only an option for GET or POST by default in the drop-down, you can just type over those and enter whatever method you like.
Christopher
A: 

This is a pretty old thread, but there is a firefox plugin called "Poster" that does what you want.

There is another plugin I've used called "Rest Client" that is also good.

Mike