in reply to Re: how to pipe url back to stdout as stream
in thread how to pipe url back to stdout as stream

Ok here's where I am now... I was writing a hotlink bypass script (not to be abused) and I've modified your script to suit that purpose:
#!/usr/bin/perl use strict; use warnings; use LWP (); print "Content-type: text/html\n\n<html><body>no url given\n" unless l +ength $ENV{QUERY_STRING}; my $ua = LWP::UserAgent->new(); my $request = HTTP::Request->new('GET', $ENV{QUERY_STRING} ); my $response = $ua->request($request, \&callback); sub callback { my ($data, $response, $protocol) = @_; unless ($response->{'callback_first'}) { $response->{'callback_first'} = 1; my $content_type = join('; ', $response->content_type()); print("Content-Type: $content_type\n"); print("\n"); } print($data); }

This is probably nothing new to you, but anyways if put on a web server with the name "file", then visiting the url:
www.mywebserver.org/cgi-bin/file?http://www.geocities.com/myhome/me.jp +g
will enable the geocities file to be hotlinked (for use off ebay etc)

HOWEVER, what I see happening is that when I save the above file (which should be called me.jpg) it actually gets sent to me with the name file.jpg.
Any idea on how to make the script preserve the original filename?

Replies are listed 'Best First'.
Re^3: how to pipe url back to stdout as stream
by mcm (Novice) on Dec 03, 2004 at 22:02 UTC
    There's an HTTP header called "Content-Disposition" that lets you pass a filename back to the browser (among other things). Try Googling for info on correct usage.
Re^3: how to pipe url back to stdout as stream
by ikegami (Patriarch) on Dec 03, 2004 at 23:36 UTC
    Just an idea... You could locally save the image you're fetching, and simply to a redirect to the local copy the next time someone asks for it.