Browse Source

forge url, and get a response (404)

nas 2 years ago
parent
commit
a90ca02942
1 changed files with 19 additions and 1 deletions
  1. 19
    1
      test/test.pl

+ 19
- 1
test/test.pl View File

5
 # @brief Remote call to the API in order to test
5
 # @brief Remote call to the API in order to test
6
 
6
 
7
 use Config::Std;
7
 use Config::Std;
8
+use LWP::UserAgent ();
9
+
8
 read_config 'test.cfg' => my %config; 
10
 read_config 'test.cfg' => my %config; 
11
+print "Username : $config{Authentification}{Username}\n";
12
+print "Host : $config{Authentification}{Host}\n";
13
+print "Host : $config{Authentification}{Path}\n";
14
+print "Protocol : $config{Authentification}{Username}\n";
9
 
15
 
10
-print "Authentification : $config{Authentification}{Username}";
16
+local $url = "$config{Authentification}{Host}$config{Authentification}{Path}";
17
+ 
18
+my $ua = LWP::UserAgent->new(timeout => 10);
19
+$ua->env_proxy;
20
+ 
21
+my $response = $ua->get( $url );
22
+ 
23
+if ($response->is_success) {
24
+    print $response->decoded_content;
25
+}
26
+else {
27
+    die $response->status_line;
28
+}

Loading…
Cancel
Save