SVN: toys/rsget.pl/Direct/HTTP
sparky
sparky at pld-linux.org
Sat Jun 26 17:02:38 CEST 2010
Author: sparky
Date: Sat Jun 26 17:02:38 2010
New Revision: 11588
Added:
toys/rsget.pl/Direct/HTTP (contents, props changed)
Log:
- plugin for downloading files directly over http protocol, avoids
downloading text/{html,xml,plain,...} and small images
Added: toys/rsget.pl/Direct/HTTP
==============================================================================
--- (empty file)
+++ toys/rsget.pl/Direct/HTTP Sat Jun 26 17:02:38 2010
@@ -0,0 +1,35 @@
+# $Id$
+# Direct::HTTP - File getter plugin for rsget.pl
+#
+# 2010 (c) Przemysław Iskra <sparky at pld-linux.org>
+# This program is free software,
+# you may distribute it under GPL v2 or newer.
+
+name: HTTP
+short: Direct::HTTP
+web: "http://rsget.pl/getters/Direct/HTTP/"
+uri: qr{http://.*[^/]}
+slots: max
+status: OK 2010-06-26
+
+start:
+ GET( $-{_uri}, headonly => 1 );
+
+ my ( $type ) = /^Content-Type:\s*(\S+)\r?$/mi;
+ my ( $len ) = /^Content-Length:\s*(\d+)\r?$/mi;
+ $len ||= -1;
+
+ ERROR( "file is text ($type)" ) if $type =~ m#^text/#;
+ ERROR( "file is a small image ($type, $len)" )
+ if $type =~ m#^image/# and $len < 100 * 1024;
+
+ my ( $name ) = $-{_uri} =~ m{.*/(.*)$};
+ if ( /^Content-Disposition:(.+?)\r?$/mi ) {
+ $name = RSGet::Curl::content_filename( $1 );
+ }
+
+ INFO( name => $name, size => $len );
+
+ DOWNLOAD( $-{_uri} );
+
+# vim: filetype=perl:ts=4:sw=4
More information about the pld-cvs-commit
mailing list