HELP: URL POST using libwww-perl and URI

Doug Matzke (matzke@dal.asp.ti.com)
Wed, 26 May 1999 17:03:16 -0500 (CDT)


Hello libwww-perl experts,

Been programming in perl/cgi for over a year, and I am trying to produce
a program the is equivalent to getprint from inside module
libwww-perl/lib/LWP/Simple.pm (but uses method POST) and having some
problems.

If someone already a simple post that is working, please send and
thanks. If someone else knows why the error message is given below:
"Can't locate auto/URI/URL/http/path_query.al" which is stored in the
object returned from $ua->request, but cgi finishes normally.  The
only place this message "locate" shows up in source using grep is:

URI/URI.pm:        die $@ if $@ && $@ !~ /Can\'t locate.*in \@INC/;
LWP/MediaTypes.pm:    # Try to locate "media.types" file, and initialize %suffixType from it
LWP/Protocol.pm:            if ($@ =~ /Can't locate/) { #' #emacs get confused by '
LWP/UserAgent.pm:               if ($@ =~ /^Can\'t locate/) {

Thanks for any help.

Doug Matzke
mailto:matzke@ti.com

  
# *********************Finished POST*********************
# _method = []POST 
# _content =
# []link_title=testing&link_description=testing%201%202%203%0A&url=http://www.ti.com%23testing&contact_p=t&Submit=t
# 
# _url = [URI::URL::http]http://www.dal.asp.ti.com/public-cgi-bin/testform.pl 
# _headers = [HTTP::Headers]HTTP::Headers=HASH(0x25e1b8) 
# 
# *********************Results are *********************
# _request = [HTTP::Request]HTTP::Request=HASH(0x25e1ac) 
# _content = [] 
# _headers = [HTTP::Headers]HTTP::Headers=HASH(0x2e402c) 
# _rc = []500 
# _msg = []Can't locate auto/URI/URL/http/path_query.al in @INC 



This is basically my debug code.
#!/usr/local/bin/perl
$posturl = 'http://www.dal.asp.ti.com/public-cgi-bin/testform.pl';
require 'cgi-lib.pl';
print &PrintHeader();

use LWP::Simple;
use lib '/data/web/cgi-bin/libwww-perl/lib';
use lib '/data/web/cgi-bin/URI';

use HTTP::Request::Common;
$ua = LWP::UserAgent->new;
print "<p>Finished New\n";
$request = POST($posturl,
		[link_title => $link_title,
		link_description => $link_description,
		url => $url,
		contact_p => $contact_p,
		Submit => $Submit || "t"]
		)  ;
print "<P>Finished POST\n";
&printobj($request);
$callback = sub { print $_[0] };
$response = $ua->request($request, $callback);
print "<p>Results are ", $response->content;
&printobj($response);
print "<P>Finished CALLBACK\n";

sub printobj {
    my ($objref, $depth) = @_;
    my (%hash, $key, $value, $type) ;
    %hash = %{$objref};
    foreach $key (keys(%hash)) {
	$value = $hash{$key};
	$type = ref($value); #use object type for debug
	if ($type eq "HASH") {
	    &printobj($value, $depth + 1);
	} else {
	    print "<br>$depth $key = [$type]", $value, "\n";
	}
    }    
}