fetch extension - use local filename from content-disposition header

From: Martin Cracauer <cracauer_at_cons.org>
Date: Thu, 29 Dec 2005 19:33:38 -0500
I'm a bit rusty, so please point me to style mistakes in the appended
diff. 

The following diff implements a "-O" option to fetch(1), which, when
set, will make fetch use a local filename supplied by the server in a
Content-Disposition header.

The most common case for this is when things are stored on a web
server by users and there handled as "attachments".  The URL filename
will say "http://foo.bar.com/attachment.php?attid=42" which is useless
as a local filename.

However, popular web software like the vBulletion forum system and
Bugzilla internally store the original filename (e.g. "mysystem.jpg"
which it was when the uploader submitted it) and provide it to the
client in a Content-Disposition header.

If you visit such an attachment in Mozilla, you will see that using
the "save" function will default to the original filename.

This extension to fetch implements the same thing.

You can test it here:
http://www.cons.org/tmp/content-disposition.cgi

Open in browser, say "save to disk", it will default to "foo.txt"
instead of "content-disposition.cgi".  Same if you use the new fetch
with -O.  Or test on any attachment on a modern version of vBulletin.

If you use Bugzilla somewhere, use this fetch to get an attachment
with "-O" and you'll be thankful that it got the original filename,
e.g. "reproduce-bug.query".

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer_at_cons.org>   http://www.cons.org/cracauer/
FreeBSD - where you want to go, today.      http://www.freebsd.org/

Received on Thu Dec 29 2005 - 23:33:41 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:49 UTC