I'll answer my own question for the record.
It's the Content-Disposition: attachment;
filename*=UTF-8''filename.zip header that causes the problem. I set
wget to use the Privoxy proxy (wgetrc line):
http_proxy = localhost:8118/
and then set Privoxy to modify incoming server headers with a Privoxy
filter:
SERVER-HEADER-FILTER: contentdisp Server Header filter to change
content-disposition
s/content-disposition: attachment;
filename\*=UTF-8''(.*)/content-disposition: attachment; filename=$1/ig
The Privoxy filter changes the server header to this form:
Content-Disposition: attachment; filename=filename.zip
which wget can read and now all is well, with the filename being saved
under the correct name.
BTW, when content_disposition=on the file seems to be saved in the root
directory, not the correct directory. With content_disposition=off, the
wrong name is used, but it's in the right place. I believe someone else
has seen this problem too (from the email archives IIRC).
Thanks for a great program!
Todd Pattist wrote:
I'm having trouble with the filename after retrieving a php generated
file download. It is retrieved with:
http://site.com/download/file.php?id=62651
The content disposition header says:
Content-Disposition: attachment; filename*=UTF-8''filename.zip
I want it to end up as filename.zip, but it ends up as
[EMAIL PROTECTED] Unfortunately, I'm dealing with hundreds of files
of varying types.
I'm using these wgetrc options:
recursive = on
content_disposition = on
verbose = on
dir_prefix = folder
server_response = on
saving the header in FireFox I see:
content-disposition: attachment; filename*=UTF-8''filename.zip
Content-Type: application/octet-stream
I'm successfully saving other files from another site with the correct
name that have a header as follows
content-disposition: attachment; filename=flower.zip
Content-Type: zip
Is my problem due to the differences in the content-disposition:
attachment; filename lines above, is it the UTF-8 or something else?
Any help or hints would be appreciated
Here's a logfile of the relevant request/response header exchange that
fails:
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Sun, 09 Mar 2008 02:31:23 GMT
Server: Apache
Pragma: public
Content-Disposition: attachment; filename*=UTF-8''filename.zip
Vary: Accept-Encoding,User-Agent
Keep-Alive: timeout=5, max=1999
Connection: Keep-Alive
Content-Type: application/octet-stream
Length: unspecified [application/octet-stream]
--2008-03-08 21:31:25-- http://site.com/download/file.php?id=62651
Connecting to site.com|70.87.3.196|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Sun, 09 Mar 2008 02:31:24 GMT
Server: Apache
Pragma: public
Content-Disposition: attachment; filename*=UTF-8''filename.zip
Content-Length: 125127
Vary: Accept-Encoding,User-Agent
Keep-Alive: timeout=5, max=2000
Connection: Keep-Alive
Content-Type: application/octet-stream
Length: 125127 (122K) [application/octet-stream]
Saving to: `foldername/site.com/download/[EMAIL PROTECTED]'