Index: trunk/DataStore/Changes
===================================================================
--- trunk/DataStore/Changes	(revision 17528)
+++ trunk/DataStore/Changes	(revision 17534)
@@ -2,4 +2,5 @@
 
 0.07
+    - Change DateStore::File to handle passing args to LWP::UserAgent
     - add dsget --timeout option
     - change dsget to return the HTTP status code on failure
Index: trunk/DataStore/lib/DataStore/File.pm
===================================================================
--- trunk/DataStore/lib/DataStore/File.pm	(revision 17528)
+++ trunk/DataStore/lib/DataStore/File.pm	(revision 17534)
@@ -1,5 +1,5 @@
 # Copyright (C) 2006  Joshua Hoblitt
 #
-# $Id: File.pm,v 1.16 2008-02-12 23:59:38 bills Exp $
+# $Id: File.pm,v 1.17 2008-05-06 02:35:22 jhoblitt Exp $
 
 package DataStore::File;
@@ -223,14 +223,22 @@
                 regex       => qr/\S+/, # string with at least 1 non WS char
             },
+            ua_args     => {
+                optional    => 1,
+            },
         },
     );
 
     # make request
-    my $ua = LWP::UserAgent->new;
+    my $ua;
+    if (defined $p{ua_args}) {
+        $ua = LWP::UserAgent->new(%{$p{ua_args}});
+    } else {
+        $ua = LWP::UserAgent->new;
+    }
     my $request = HTTP::Request->new(GET => $self->uri);
     my $filename = $p{filename};
     my $response = $ua->request($request, $filename);
 
-    IS_SUCCESS: if ($response->is_success) {
+    if ($response->is_success) {
         # check size
         if (defined $self->bytes) {
@@ -243,9 +251,8 @@
                 # set the filename to undef to indicate an error
                 $filename = undef;
-                last IS_SUCCESS;
             }
         }
 
-        if (defined $self->md5sum) {
+        if (defined $filename and defined $self->md5sum) {
             my $md5 = file_md5_hex($filename);
             if (! ($self->md5sum eq $md5)) {
@@ -256,5 +263,4 @@
                 # set the filename to undef to indicate an error
                 $filename = undef;
-                last IS_SUCCESS;
             }
         }
Index: trunk/DataStore/scripts/dsget
===================================================================
--- trunk/DataStore/scripts/dsget	(revision 17528)
+++ trunk/DataStore/scripts/dsget	(revision 17534)
@@ -3,5 +3,5 @@
 # Copyright (C) 2006-2008  Joshua Hoblitt
 #
-# $Id: dsget,v 1.19 2008-05-05 20:45:53 jhoblitt Exp $
+# $Id: dsget,v 1.20 2008-05-06 02:35:22 jhoblitt Exp $
 
 use strict;
@@ -67,8 +67,9 @@
 
 # default http request timeout is 30s
+$timeout ||= 30;
+
 my %p = (
     uri     => $uri,
     type    => 'chip',
-    timeout => $timeout ||= 30,
 );
 
@@ -123,5 +124,8 @@
 
 # request the file from the remote data store server (save in tmpfilename)
-my $response = DataStore::File->new(%p)->request( filename => $tmpfilename );
+my $response = DataStore::File->new(%p)->request(
+    filename => $tmpfilename,
+    ua_args  => { timeout => $timeout},
+);
 
 die "request failed" unless defined $response;
