in reply to how to upload a file to a secured website?
#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request::Common qw(POST); my $https_url = 'https://zentara.zentara.net/~zentara/cgi-bin/uploads/ +up1.cgi'; my $https_user = 'zentara'; my $https_pass = 'foobar'; my $file = 'testout.tgz'; &postHTTPS(); sub postHTTPS { my $ua = new LWP::UserAgent; $ua->protocols_allowed( [ 'https'] ); $ua->cookie_jar(HTTP::Cookies->new(file =>".cookies.txt",autos +ave => 1)); #setup request my $req = POST($https_url, Content_Type => 'multipart/form-data', Content =>[ file =>[ $file ], ], ); #setup auth $req->authorization_basic($https_user, $https_pass); #do post my $response = $ua->request($req); if ($response->is_error()) { printf " %s\n", $response->status_line; print "https request error!\n"; } else { my $content = $response->content(); print "$content\n"; } if ( $response->is_success ) { print $response->as_string; }else { print $response->status_line; } }
#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; my $href = "http://kompas.com/kompas-cetak/0505/09/metro/index.htm +"; my $ua = new LWP::UserAgent; my $request = new HTTP::Request ("GET" => $href); $ua->env_proxy, $request->proxy_authorization_basic($ENV{HTTP_proxy_user}, $ENV{HTTP_p +roxy_pass}) if defined $ENV{HTTP_proxy}; my $response = $ua->request($request); if ($response && $response->is_success) { print "Success!\n", $response->content; } else { print "Failed!\n", $response->as_string; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to upload a file to a secured website?
by KarthikK (Sexton) on Oct 17, 2007 at 07:29 UTC | |
|
Re^2: how to upload a file to a secured website?
by KarthikK (Sexton) on Oct 17, 2007 at 13:08 UTC | |
by zentara (Cardinal) on Oct 17, 2007 at 15:25 UTC | |
by KarthikK (Sexton) on Oct 17, 2007 at 15:41 UTC | |
by zentara (Cardinal) on Oct 17, 2007 at 17:32 UTC | |
by KarthikK (Sexton) on Oct 17, 2007 at 19:21 UTC | |
by zentara (Cardinal) on Oct 18, 2007 at 12:48 UTC |