Skip Menu |

This queue is for tickets about the Net-Async-HTTP CPAN distribution.

Report information
The Basics
Id: 53703
Status: resolved
Priority: 0/
Queue: Net-Async-HTTP

People
Owner: Nobody in particular
Requestors: tao.yang [...] bankofamerica.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.06



Subject:
Date: Thu, 14 Jan 2010 16:33:49 -0500
To: bug-Net-Async-HTTP [...] rt.cpan.org
From: "Yang, Tao" <tao.yang [...] bankofamerica.com>
Net-Async-HTTP-0.05 Perl: This is perl, v5.8.8 built for x86_64-linux-thread-multi Machine: Linux sv6nastst01.ten-net.net 2.6.18-128.1.14.el5 #1 SMP Mon Jun 1 15:52:58 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux 1)Here is my testing script: async_test.pl, which is made from your example: #!/usr/bin/perl use URI; use IO::Async::Loop; use Net::Async::HTTP; my $xml_request= qq[<?xml version="1.0" ?> <Request request_id="100002" action="inq_io" requestor="cpaas" password="fakepwd"> <tier_name>silver</tier_name> </Request>\n]; my $loop = IO::Async::Loop->new(); my $http = Net::Async::HTTP->new(); $loop->add( $http ); $http->do_request( uri => URI->new( "http://171.133.181.177/cgi-bin/sbb.pl" ), method=>'POST', content =>$xml_request , user => 'cpaas', pass => 'fakepwd', on_response => sub { my ( $response ) = @_; print "Server response is:\n"; print $response->content; $loop->loop_stop; }, on_error => sub { my ( $message ) = @_; print "Cannot fetch http://171.133.181.177/ - $message\n"; $loop->loop_stop; }, ); $loop->loop_forever; 2)the cgi script: sbb.pl #!/usr/bin/perl -w use strict; $|++; use lib '/opt/sbb/libs'; use CGI; use SBB; my $q = new CGI; print $q->header( "text/plain" ); my $xml_request = $q->param( 'POSTDATA' ); print CGI::header(); print "No XML data" if(!$xml_request); my $resp = (SBB::process_request($xml_request)); print $resp; 3)when I try to run my testing script through WEB, I always get "No XML data" error. I follow your instruction to fill uri, method, content field. I think if the XML data did not pass to cgi script, this should be a bug. Thanks

Message body is not shown because it is too large.

On Thu Jan 14 16:34:24 2010, tao.yang@bankofamerica.com wrote: Show quoted text
> 1)Here is my testing script: async_test.pl, which is made from your > example:
... <snip> Show quoted text
> 3)when I try to run my testing script through WEB, I always get "No > XML data" error.
... Show quoted text
> I follow your instruction to fill uri, method, content field. I think > if the XML data did not pass to cgi script, this should be a bug.
If I edit your script to point it at 127.0.0.1:18080 instead and run it pointed at a local socat client to test it, I get the following: --- $ socat TCP-LISTEN:18080,crnl STDIO POST /cgi-bin/sbb.pl HTTP/1.1 Authorization: Basic Y3BhYXM6ZmFrZXB3ZA== Host: 127.0.0.1 User-Agent: Perl + Net::Async::HTTP/0.05 Content-Length: 149 Content-Type: application/x-www-form-urlencoded <?xml version="1.0" ?> <Request request_id="100002" action="inq_io" requestor="cpaas" password="fakepwd"> <tier_name>silver</tier_name> </Request> --- That looks suspect; it's claiming application/x-www-form-urlencoded even though the data isn't. But anyway, at this point I type an HTTP response at it: --- HTTP/1.1 200 OK Content-Type: text/plain Content-Length: 13 All is well --- The script itself prints: --- $ perl async_test.pl Server response is: All is well --- The problem comes that your CGI script doesn't get any POSTDATA because it was told the content type was application/x-www-form-urlencoded, even though it wasn't: --- $ REQUEST_METHOD=POST CONTENT_LENGTH=149 CONTENT_TYPE=application/x-www-form-urlencoded perl -MCGI -E 'say "POSTDATA is >>" . CGI->new->param("POSTDATA")' <?xml version="1.0" ?> <Request request_id="100002" action="inq_io" requestor="cpaas" password="fakepwd"> <tier_name>silver</tier_name> </Request> POSTDATA is >> --- I suggest instead constructing the HTTP::Request object yourself, so you can provide the correct content type (I suggest in your case it ought to be text/xml or something): --- $ REQUEST_METHOD=POST CONTENT_LENGTH=149 CONTENT_TYPE=text/xml perl -MCGI -E 'say "POSTDATA is >>" . CGI->new->param("POSTDATA")' <?xml version="1.0" ?> <Request request_id="100002" action="inq_io" requestor="cpaas" password="fakepwd"> <tier_name>silver</tier_name> </Request> POSTDATA is >><?xml version="1.0" ?> <Request request_id="100002" action="inq_io" requestor="cpaas" password="fakepwd"> .... --- That should help. -- Paul Evans
On Fri Jan 15 15:07:52 2010, PEVANS wrote: Show quoted text
> That looks suspect; it's claiming application/x-www-form-urlencoded > even though the data isn't.
... Show quoted text
> The problem comes that your CGI script doesn't get any POSTDATA > because it was told the content type was > application/x-www-form-urlencoded, even though it wasn't:
... Show quoted text
> I suggest instead constructing the HTTP::Request object yourself, so > you can provide the correct content type (I suggest in your case it > ought to be text/xml or something):
Just so you know, you can now supply the content type directly as of Net::Async::HTTP 0.06, which is now on CPAN. -- Paul Evans
Subject: RE: [rt.cpan.org #53703] Resolved:
Date: Mon, 01 Feb 2010 09:47:02 -0500
To: bug-Net-Async-HTTP [...] rt.cpan.org
From: "Yang, Tao" <tao.yang [...] bankofamerica.com>
Yes. Thanks for the help. Tao Show quoted text
-----Original Message----- From: Paul Evans via RT [mailto:bug-Net-Async-HTTP@rt.cpan.org] Sent: Sunday, January 31, 2010 12:13 PM To: Yang, Tao Subject: [rt.cpan.org #53703] Resolved: <URL: https://rt.cpan.org/Ticket/Display.html?id=53703 > According to our records, your request has been resolved. If you have any further questions or concerns, please respond to this message.
Subject: RE: [rt.cpan.org #53703] Resolved:
Date: Tue, 08 Jun 2010 15:41:20 -0400
To: bug-Net-Async-HTTP [...] rt.cpan.org
From: "Yang, Tao" <tao.yang [...] bankofamerica.com>
Evans, Sorry to bother you again. Based on your suggestion, I changed my script as following(add content_type): 1) use URI; use IO::Async::Loop; use Net::Async::HTTP; my $xml_request= qq[<?xml version="1.0" ?> <Request request_id="100002" action="inq_io" requestor="cpaas" password="auto1cloud"> <tier_name>silver</tier_name> </Request>\n]; my $loop = IO::Async::Loop->new(); my $http = Net::Async::HTTP->new(); $loop->add( $http ); $http->do_request( uri => URI->new( "http://171.133.181.177/cgi-bin/sbb_asyn.pl" ), method=>'POST', content =>$xml_request , content_type => 'text/xml', user => 'cpaas', pass => 'auto1cloud', on_response => sub { my ( $response ) = @_; print "Server response is:\n"; print $response->content; $loop->loop_stop; }, on_error => sub { my ( $message ) = @_; print "Cannot fetch http://171.133.181.177/ - $message\n"; $loop->loop_stop; }, ); $loop->loop_forever; However, I still can not get the XML data. 2)sbb_asyn.pl use strict; $|++; use lib '/opt/sbb/libs'; use CGI; use SBB; my $q = new CGI; print $q->header( "text/html" ); my $xml_request = $q->param( 'PUTDATA' ); print CGI::header(); print "\nNo XML data\n" if(!$xml_request); Thanks Show quoted text
-----Original Message----- From: Paul Evans via RT [mailto:bug-Net-Async-HTTP@rt.cpan.org] Sent: Thursday, May 20, 2010 12:50 PM To: Yang, Tao Subject: [rt.cpan.org #53703] Resolved: <URL: https://rt.cpan.org/Ticket/Display.html?id=53703 > According to our records, your request has been resolved. If you have any further questions or concerns, please respond to this message.
On Tue Jun 08 15:41:37 2010, tao.yang@bankofamerica.com wrote: Show quoted text
> $http->do_request( > method=>'POST',
<snip> Show quoted text
> However, I still can not get the XML data.
<snip> Show quoted text
> my $xml_request = $q->param( 'PUTDATA' );
Surely you mean POSTDATA? The method was POST so the data will appear under POSTDATA. PUTDATA is for the PUT method. See also http://search.cpan.org/~lds/CGI.pm-3.49/lib/CGI.pm#HANDLING_NON-URLENCODED_ARGUMENTS -- Paul Evans
Subject: RE: [rt.cpan.org #53703]
Date: Mon, 14 Jun 2010 14:11:55 -0400
To: bug-Net-Async-HTTP [...] rt.cpan.org
From: "Yang, Tao" <tao.yang [...] bankofamerica.com>
Oops. It is 'POSTDATA' in my code. $xml_request = $q->param( 'POSTDATA' ); Anyway, I still did not get XML data. Tao Show quoted text
-----Original Message----- From: Paul Evans via RT [mailto:bug-Net-Async-HTTP@rt.cpan.org] Sent: Monday, June 14, 2010 2:05 PM To: Yang, Tao Subject: [rt.cpan.org #53703] <URL: https://rt.cpan.org/Ticket/Display.html?id=53703 > On Tue Jun 08 15:41:37 2010, tao.yang@bankofamerica.com wrote:
> $http->do_request( > method=>'POST',
<snip>
> However, I still can not get the XML data.
<snip>
> my $xml_request = $q->param( 'PUTDATA' );
Surely you mean POSTDATA? The method was POST so the data will appear under POSTDATA. PUTDATA is for the PUT method. See also http://search.cpan.org/~lds/CGI.pm-3.49/lib/CGI.pm#HANDLING_NON-URLENCODED_ARGUMENTS -- Paul Evans
Subject: Net:Async::http question [rt.cpan.org #53703]
Date: Wed, 16 Jun 2010 09:52:16 -0400
To: bug-Net-Async-HTTP [...] rt.cpan.org
From: "Yang, Tao" <tao.yang [...] bankofamerica.com>
Hello, In your perl module description, you mentioned that: The following named arguments are used for HTTP::Requests: request => HTTP::Request A reference to an HTTP::Request object host => STRING port => INT Hostname and port number of the server to connect to I have a Apache server which has a “directory” protected by certain authentication. So if I construct HTTP: request, how do I do authentication in “do_request” method? In my current regular HTTP::Request application, I do something like this: my $ua = LWP::UserAgent->new; $ua->credentials('171.133.181.177:80', 'System Automation SBB Site', 'serge_v'=>'sergespw'); But I have no idea how to do the similiar thing using your module when construct HTTP::Request by myself. Thanks Show quoted text
-----Original Message----- From: Paul Evans via RT [mailto:bug-Net-Async-HTTP@rt.cpan.org] Sent: Thursday, May 20, 2010 12:50 PM To: Yang, Tao Subject: [rt.cpan.org #53703] Resolved: <URL: https://rt.cpan.org/Ticket/Display.html?id=53703 > According to our records, your request has been resolved. If you have any further questions or concerns, please respond to this message.
On Wed Jun 16 09:52:33 2010, tao.yang@bankofamerica.com wrote: Show quoted text
> I have a Apache server which has a “directory” protected by certain > authentication. So if I construct HTTP: request, how do I do > authentication in “do_request” method?
That would be the $req->authorization_basic( $user, $pass ) method on HTTP::Headers; see http://search.cpan.org/~gaas/libwww-perl-5.837/lib/HTTP/Headers.pm I'm going to close this bug ticket now because it isn't strictly speaking, a bug. If you require further assistance you can contact me directly by email, or you might want to try IRC; #ioasync on irc.perl.org, or private message to "LeoNerd". Thanks, -- Paul Evans