Sfoglia il codice sorgente

forge url, and get a response (404)

nas 2 anni fa
parent
commit
a90ca02942
1 ha cambiato i file con 19 aggiunte e 1 eliminazioni
  1. 19
    1
      test/test.pl

+ 19
- 1
test/test.pl Vedi File

@@ -5,6 +5,24 @@
5 5
 # @brief Remote call to the API in order to test
6 6
 
7 7
 use Config::Std;
8
+use LWP::UserAgent ();
9
+
8 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…
Annulla
Salva