Discuss Https POST sample code in the Perl Programming forum on Dev Shed. Https POST sample code Perl Programming forum discussing coding in Perl, utilizing Perl modules, and other Perl-related topics. Perl, the Practical Extraction and Reporting Language, is the choice for many for parsing textual information.
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month! Download and Activate to enter!
Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.
Posts: 44
Time spent in forums: < 1 sec
Reputation Power: 11
Https POST sample code
Hmmm...
#!/usr/bin/perl
# requires crypt-ssleay installed
# OR ERR = 501 Protocol scheme 'https' is not supported
# SEE : http://www.linpro.no/lwp/
# windows: ppm install crypt-ssleay [ tested on win98, apache1.3.9, perl 5.60 ]
# Linux : Crypt-SSLeay-0.27.tar.gz -- read notes requires openssl... basically more required
print "Content-type: text/html\n\n";
use HTTP::Request::Common qw(POST GET);
use HTTP::Headers;
use LWP::UserAgent;
# this is the info we are POST-ing to the script
$A = "Hello";
$B = "World";
$C = "I am";
$D = "Here";
# set up the stuff
my $ua = LWP::UserAgent->new();
# Set our own user-agent string!
$ua->agent("PerlZilla/v1.01 RHLinux");
my $url = "https://www.YourTarget.com/cgi-bin/file.cgi";
# file.cgi should just return the data sent for this test
# These seem to be like <input type=text name=A value=$A > off a form...
my $req = POST $url, [
A => "$A",
B => "$B",
C => "$C",
D => "$D" # no comma here Eh !
];
# Fire the cannon now !
my $res = $ua->request($req);
# Get the error back from the server if any
my $err = $res->status_line;
# Get server body text, $_ used in regexp on next line
$_ = $res->as_string;
if (/Illegal Operation/ig || $err != 200) {
print "Server returned error: $err\n";
exit 1;
}
# Just print the whole wack of stuff
print "$_";
# RAW info back for debug -- contains header stuff
Posts: 44
Time spent in forums: 27 m 55 sec
Reputation Power: 0
Hi,
i have just gone thru all the rigamarol of installing the crypt ssleay module to get posts to work over https. here is a list of all the modules that needed installing
Location: the far end of town where the Grickle-grass grows
Posts: 1,860
Time spent in forums: 4 Days 11 h 6 m
Reputation Power: 106
If you're in windows and want LWP and SSL, try this: http://johnbokma.com/perl/https.html
The kicker is the non-standard ppd at http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd. I guess it isn't included by default so ActiveState doesn't have to worry about encryption exportation laws?
After that's installed, LWP works transparently with SSL. The ppd copied a pair of DLL's down to perl's bin directory (in path). In my case, I needed to upload a file, a normal text parameter, and post over SSL with basic http authentication. First the html form, then the Perl code to post to it.
Code:
<form enctype="multipart/form-data" action="https://url.to/post/to"
method="post">
File to process: <input name="FileParamName" type="file"><br>
File to process: <input name="FileParamName" type="file"><br>
File to process: <input name="FileParamName" type="file"><br>
Other form input:
<input name="FileParamName" value="A simple form input value"><br>
<input type="submit" value="Upload">
</form>
Code:
use LWP::UserAgent;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new;
my $req = POST(
'https://url.to/post/to',
Content_Type => 'form-data',
Content => [ NormalParamName => 'A simple form input value',
FileParamName => ['file-to-upload.txt'],
],
);
$req->authorization_basic('username', 'password');
print $ua->request($req)->as_string;
I just had to poke at this today and figured I'd share.
__________________
Andrew - Perl (and VB.NET) Monkey
Never underestimate the bandwidth of a hatchback full of tapes.