I'm using mechanize for scraping a website which works nicely, however since you can't tell from a link what kind of file it is linking to e.g. <http://somesite.com/images.php?get=123>
is it possible to download the header only?

I'm asking this because I'd like to decide based on the filetype if I will download it.
Also it would then help deciding on a filename when downloading. 

It doesn't have to use mechanize but is there any Rails way of doing this?