SVN: toys/rsget.pl/Direct/HTTP
sparky
sparky at pld-linux.org
Sat Jun 26 19:05:40 CEST 2010
Author: sparky
Date: Sat Jun 26 19:05:39 2010
New Revision: 11594
Modified:
toys/rsget.pl/Direct/HTTP
Log:
- added "file not found" detection (HTTP 404)
- fixed content-type detection
- improved filename detection in case of redirect
Modified: toys/rsget.pl/Direct/HTTP
==============================================================================
--- toys/rsget.pl/Direct/HTTP (original)
+++ toys/rsget.pl/Direct/HTTP Sat Jun 26 19:05:39 2010
@@ -15,7 +15,10 @@
start:
GET( $-{_uri}, headonly => 1 );
- ! my ( $type ) = /^Content-Type:\s*(\S+?)(;.*?)\r?$/mi;
+ ERROR( "file not found" ) if /^HTTP\S+ 404/s;
+
+ my @type = /^Content-Type:\s*(\S+?)(?:;.*?)?\r?$/mig;
+ ! my $type = pop @type;
my ( $len ) = /^Content-Length:\s*(\d+)\r?$/mi;
$len ||= -1;
@@ -23,7 +26,7 @@
ERROR( "file is a small image ($type, $len)" )
if $type =~ m#^image/# and $len < 100 * 1024;
- my ( $name ) = $-{_uri} =~ m{.*/(.*)$};
+ my ( $name ) = $-{_referer} =~ m{.*/(.*)$};
if ( /^Content-Disposition:(.+?)\r?$/mi ) {
$name = RSGet::Curl::content_filename( $1 );
}
More information about the pld-cvs-commit
mailing list