473,586 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving a page generated by a NPH cgi script

4 New Member
Hello,

I'm having problems using LWP::UserAgent and HTTP::Request:: Common when trying to retrieve a dynamic page generated by a cgi script.

I've got it to the point where I receive a page, but it has none of the dynamic content, and it has several sections that say:
"WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY"

Now, a bit of googling has narrowed it down, and I think the problem is that the LWP::* and HTTP::* don't support nph responses. The only info I can find through google is all concerned with using the perl script on the server-side, but I want to use a perl script as the client.

For added info, I'm actually trying to query a bugzilla installation (e.g:
http://bugzilla/show_bug.cgi?qu ery_format=spec ific&bug_status =__open__&produ ct=&content=com and+injection

I've tried setting as much as I can in the userAgent
I wouldn't be surprised if I'm going about this completely the wrong way, but any pointers would be appreciated. (code sniuppet below)

Thanks,

Andy

Expand|Select|Wrap|Line Numbers
  1. use HTTP::Request::Common;
  2. use LWP::UserAgent;
  3.  
  4. my  $ua = LWP::UserAgent->new;
  5.  
  6. $ua->agent('Firefox/2.0.0.6');  # Also tried  #Mozilla/5.0
  7. push @{ $ua->requests_redirectable }, 'GET';
  8.  
  9. my $Outputfile = "a.htm";
  10. open OUTPUTFILE, ">$Outputfile";
  11.  
  12. $res = $ua->request(  POST 'http://bugzilla/buglist.cgi', Content_Type => 'multi-part/form-data', Content =>   [ query_format => "specific", bug_status   => "__open__" , product => , content=>"command injection" ]);
  13.  
  14.  
  15.   if ($res->is_success) {
  16.       print OUTPUTFILE $res->content;
  17.   }
  18.   else {
  19.       print $res->status_line, "\n";
  20.   }
  21.  
Aug 13 '07 #1
3 2870
miller
1,089 Recognized Expert Top Contributor
Greetings Andy and welcome,

A few notes.

Adding 'GET' to request_redirec table is redundant, as the default for LWP::UserAgent is to follows GET and HEAD method redirections. I suspect that this was probably just a debugging addition.

Consecutive commas in an array definition are colapsed. Therefore the product will actually be set equal to "content", which I wouldn't be surprised might cause some problems. Put in a hard undef or empty string there instead for a null value.

I typically separate my request declaration from the actual request call. This purely a stylistic preference, but I consider it easier to debug the statement if it is expanded out on multiple lines. Also, this makes it easier to throw in a quick "use Data::Dumper; print Dumper($req);" call or "print $req->as_string;" to confirm that things are formatted as you expect.

Finally, try using a full user agent. I don't know what type of browser specific codes that bugzilla looks for, but the easiest way to ensure that the user_agent isn't the problem is to simply use your own browser user agent string. The follow code uses my own computers.

Finally ** 2. Always "use strict;";.

Expand|Select|Wrap|Line Numbers
  1. use HTTP::Request::Common;
  2. use LWP::UserAgent;
  3.  
  4. use strict;
  5.  
  6. my $ua = LWP::UserAgent->new;
  7. $ua->agent("Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
  8.  
  9. # push @{ $ua->requests_redirectable }, 'GET';
  10.  
  11. my $req = POST 'http://bugzilla/buglist.cgi',
  12.         Content_Type => 'form-data',
  13.         Content => [
  14.             query_format => "specific",
  15.             bug_status   => "__open__" ,
  16.             product      => undef,
  17.             content      => "command injection",
  18.         ];
  19.  
  20. my $res = $ua->request($req);
  21.  
  22. if ($res->is_success) {
  23.     my $outfile = "a.htm";
  24.     open(OUTFILE, ">$outfile") or die "Can't open $outfile: $!";
  25.     print OUTFILE $res->content;
  26.     close OUTFILE;
  27. }
  28. else {
  29.     print $res->status_line, "\n";
  30. }
  31.  
- Miller
Aug 14 '07 #2
AndyHunt
4 New Member
Hey Miller !

Thanks very much - that hits the spot.

For completeness, a couple more observations:
- When I changed the ua->agent to what you suggested, although the script pulled the entire page, I still received the warnings about "your browser doesn't support...etc".
If I didn't set out $ua->agent(..... at all, then the page is 100% perfect! I'm not sure what's going on there, but.....

- If I set
Expand|Select|Wrap|Line Numbers
  1. product => , 
then the retrieval of the page works, just doesn't return any results (due, as you predicted, to product being wrong.)

So it looks like a combination of the above two was giving me a page (a) with no results because the product was wrong, and (b) with the error message!


Thank you very much for you help,

Andy
Aug 14 '07 #3
miller
1,089 Recognized Expert Top Contributor
Great!

Yes, it's sometimes hard figuring out what code is intentional, and which code is just from fiddling in the effort to get things to work. Glad to hear it's working.

- Miller
Aug 14 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1790
by: Chris Shipley | last post by:
I am trying to present a list of links on a page (Form) where each link opens a different picture gallery. I have the Form page which contains the links, a Gallery page, and several include files. Each include file displays a different gallery. Clicking on a link submits a value identifying the chosen gallery to the Gallery page. The Gallery...
4
1919
by: Lan Vuong | last post by:
Hi everyone, I'm trying to retrieve the width of a cell as the table is being dynamically created and add it to a total. I can get the width from an eventhandler such as: <td onmouseover="alert(this.width);"> but I don't want to require any user action.
31
4108
by: Greg Scharlemann | last post by:
Given some recent success on a simple form validation (mainly due to the kind folks in this forum), I've tried to tackle something a bit more difficult. I'm pulling data down from a database and populating a simple table. I'd like the table to contain 10 entries per page and have the option for the user to scroll through the pages of data...
1
9439
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when I try to create my SQL connection in the code-behind, I get the following error. I tried to register the DLL using regsvr32 but that errored out...
2
4226
by: ste-m | last post by:
Hi there, I was wanting to calculate how long my web pages take to load, and to insert this time into my HTML source code (not visible from the browser, but only in source view) as a HTML comment. I've found a JavaScript that does this here: http://www.twohootssoftware.co.uk/code/loadtimejs.html <script language="javascript"...
14
23138
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So, we're looking for a way to display the page with a "please wait..." message while the process is running, and then, when the process is done, update...
0
3375
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to...
3
2118
by: ajos | last post by:
Hello friends, In my action class i am getting a resultset data which im storing in a arraylist. In my jsp page im retrieving the arraylist data as-----> <%publicity.PendingReqForm prfObj=null; ArrayList req=(ArrayList) request.getAttribute("req"); for(Iterator it= req.iterator();it.hasNext();){ prfObj=(PendingReqForm) it.next();{ %>
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.