On Tue, Oct 31, 2000 at 02:54:39PM -0500, John Soto wrote:
>
> Having problem reading POSTed content.... Am trying to write handler which will
> pass content onto MQ. Currently, I have the content as text\plain and not
> url-encoded.
> Here's my POSTing snippet...
>
> #! /usr/bin/perl -w
>
> use LWP::UserAgent;
> use HTTP::Request;
>
> $ua = LWP::UserAgent->new();
> $ua->agent("$0/1.0");
> $url = "http://tssdatadev.jc.jefco.com/wilco/PutXml/asynch";
>
> $req = new HTTP::Request 'POST',$url;
>
> $req->content_type('text/plain');
> #$req->content_type('multipart/form-data');
>
> $req->content_length(33);
> $req->content("easter bunny is coming to town...");
> $resp = $ua->request($req);
> print $resp->as_string;
Are you sure you can POST with a content-type of text/plain? I made a little script
for some automatic form submitting where I did this (fitted in for your needs):
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use HTTP::Request;
use URI::Escape;
my $ua = new LWP::UserAgent;
$ua->agent("$0/1.0");
my $req = new HTTP::Request(POST =>
'http://tssdatadev.jc.jefco.com/wilco/PutXml/asynch');
$req->content_type('application/x-www-form-urlencoded');
$req->content(uri_escape("easter bunny is coming to town...");
my $resp = $ua->request($req);
if ($res->is_success) {
print $req->as_string;
} else {
print "Bad luck this time\n";
}
__END__
Try with this snippet and see how your POST goes..
--
Thomas Eibner
> Here's a snippet of the handler. I'm using read() to get the content... I
> receive the content-length with no problem, but am unable to read the content.
>
>
>
> package WILCO::PutXml;
>
> #use strict "refs";
>
> use Apache::Constants qw(:common);
> use Apache::Registry;
> use MQSeries;
> use CGI;
> use Carp;
>
> do 'Constants.pl';
> use lib '/apps/lib/perl';
> require 'jefco.pm';
>
> sub handler {
>
> my $r = shift;
>
>
> # Parse out how I'm being called
> my($method);
> ($method=$r->uri)=~s!^.*/wilco/PutXml/(\w+)!$1!;
> $method =~ s/\?.*//;
>
> # Get my arguments
> # my($http) = new CGI( $r->args || $r->content );
> # my %params = ($r->content, $r->args);
>
>
> # Autoflush the output buffer
> $| = 1;
> open(XML,">/tmp/xml.log") || die "Cannot create log file: $!\n";
>
>
> $r->content_type('text/html');
> $r->header_out('pragma','no-cache');
> $r->send_http_header;
>
>
> $r->warn ("<!-- --------------------------- -->\n");
> $r->warn ("<!-- START PROGRAM - PutXml -->\n");
> $r->warn ("<!-- Method = $method -->\n");
>
> ############################################################################
> # setup defaults, and envionment vairiables
> ############################################################################
>
> $ENV{MQSERVER} = $MQSERVER;
>
> my $PutQ = 'QL.WILCO.IN';
> my $GetQ1 = 'QL.WILCO.SYNC.OUT';
> my $GetQ2 = 'QL.WILCO.ASYNC.OUT';
>
> my $Msg;
> $r->read($Msg, $r->header_in('Content-length'));
>
> $r->warn ("<!-- ------------------------- -->");
> $r->warn ("<!-- ENVIRONMENT VARIABLES : -->");
> $r->warn ("<!-- mqserver = $MQSERVER -->");
> $r->warn ("<!-- Queue Manager= $QM -->");
> if (!($Msg)){$r->warn ("<!-- Msg = $Msg -->");}
>
> I get nothing in $Msg... What am I missing here???
>
> Thanks in advance!