#!/usr/bin/perl -w
use strict 'subs';
use LWP::UserAgent;
BEGIN { $ENV{PATH} = '/usr/bin:/bin' }
require LWP::UserAgent;
$URL = "http://localhost/Test.asp";
print "Posting to the page '$URL'.\n";
($returnedPage) = DoPost ($URL);
print "Dispaying POSTed results:\n";
print "="x72."\n$returnedPage\n"."="x72."\n";
exit;
sub DoPost {
local ($url) = @_;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $browserType = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
my $httpReferer = "http://www.PerlMonks.org";
my $userAgent = new LWP::UserAgent;
$userAgent->agent("$browserType ");
my $request = POST "$url",
[
Value1 => 'Some value for 1',
Value2 => 'My value 2 result',
Value3 => 'My value 3'
];
$request->referer("$httpReferer");
# Post the request to the server
my $response = $userAgent->request($request)->as_string;
return ($response);
}
##
<%
Call WriteQueryStringContents()
Sub WriteQueryStringContents
Dim strItem
Response.Write CHR(10) & " " & CHR(10)
Response.Write "QueryString contents:" & CHR(10)
For Each strItem In Request.QueryString
Response.Write " " & CHR(10)
Response.Write "Form contents:" & CHR(10)
For Each strItem In Request.Form
Response.Write "##
This page writes out POSTed FORM values:
##
E:\Personal>perl http_post.pl
Posting to the page 'http://localhost/Test.asp'.
Dispaying POSTed results:
========================================================================
HTTP/1.1 200 OK
Cache-Control: private
Connection: Keep-Alive
Date: Tue, 20 Nov 2001 20:54:11 GMT
Server: Microsoft-IIS/5.0
Content-Length: 201
Content-Type: text/html
Client-Date: Tue, 20 Nov 2001 20:54:11 GMT
Client-Peer: 127.0.0.1:80
Set-Cookie: ASPSESSIONIDQGGGQNOK=LEDDBLNAMNEONOJLKHFDFANJ; path=/
This page writes out POSTed FORM values:
QueryString contents:
Form contents:
Value1: Some value for 1
Value2: My value 2 result
Value3: My value 3
========================================================================