Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

contrib/LWPsearch.pl: simplify a bit

  • Loading branch information...
commit 368bd7676058964dcb1a4177198b005492c2ec9c 1 parent 5f234b0
@marschap marschap authored
Showing with 6 additions and 7 deletions.
  1. +6 −7 contrib/LWPsearch.pl
View
13 contrib/LWPsearch.pl
@@ -28,18 +28,17 @@
my $ua = LWP::UserAgent->new;
$ua->agent("LWPsearch");
-# create a request
-my $req = HTTP::Request->new(GET => $ARGV[0]);
+# add headers as requested
+my %headers = ();
-# add headers
-$req->header('Accept' => "text/$format")
+$headers{Accept} = "text/$format"
if ($format);
-$req->header('Authorization' => 'Basic '.encode_base64("$user:$password"))
+$headers{Authorization} = 'Basic '.encode_base64("$user:$password")
if ($user);
-# pass request to the user agent and get a response back
-my $res = $ua->request($req);
+# pass GET request to the user agent and get a response back
+my $res = $ua->get($ARGV[0], %headers);
# check the outcome of the response
if ($res->is_success) {
Please sign in to comment.
Something went wrong with that request. Please try again.