POST command

Shyamsunder, MT (MT.Shyamsunder@geind.ge.com)
Tue, 9 Jan 2001 15:57:06 +0530


------_=_NextPart_000_01C07A26.B7231710
Content-Type: text/plain;
	charset="iso-8859-1"

The enclosed program works well when I use the Netscape server. But when we
use WebLogic server, the contents which the client program (caller.pl) sends
to the server program(reciever.pl) are not being written to the file.
Please help us know, are there any parameters that need to be set in the
POST method, for the transfer of the contents. 
We see that, if the content_type is set in the client program,then the data
from the server doesn't reach the clientif we use Netscape server[ if we
donot set content_type,then it works with Netscape server. WebLogic server
requires this to be set]. Similar to this, please let us know if there are
any specific settings for the POST method to use with WebLogic server.
	



------_=_NextPart_000_01C07A26.B7231710
Content-Type: application/octet-stream;
	name="reciever.pl"
Content-Disposition: attachment;
	filename="reciever.pl"

#!/usr/bin/perl -w
@INC = ();

print "content-type: text/html\n\n";     # Required header, may change type
require "CGI.pm"; 
use CGI;                             # Module for processing CGI requests
use CGI::Carp; #this module is to log the errors that occur on the server side program


#output all the errors that occur on server side to a log file
BEGIN
{
   use CGI::Carp qw(carpout);
   open(LOG,">d:/perl/cgilog.txt") or die "unable to log the contents";
   carpout(*LOG);

}


$query = new CGI;                        # Build query object from request
$file = $query->param("Filecontents"); # get the input from the client
$infile = "d:/temp/FilefromCaller";          # Where to stick the contents from Client



open(INFILE,">$infile"); 
print INFILE $file;  
$streamstring = "this is the contents from the server";
print $streamstring;


close(INFILE);


------_=_NextPart_000_01C07A26.B7231710
Content-Type: application/octet-stream;
	name="Caller.pl"
Content-Disposition: attachment;
	filename="Caller.pl"

use LWP::Simple;
use URI::URL;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;


$ua = LWP::UserAgent->new(); #create a user agent
#post the message to the server
#this will activate the program that needs to run
#in this program, reciever.pl will run on the server side
$streamstring = "string to be passed to the server";
my  $req = POST 'http://3.212.228.149/cgi-bin/reciever.pl',[Filecontents =>$streamstring];
$req->content_type('application/x-www-form-urlencoded');
$req->content('match=www&errors=0');

#content is what the server sends back after processing
$content = $ua->request($req)->as_string; 
print $content;

------_=_NextPart_000_01C07A26.B7231710--