Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

No Host Option provided in Net::HTTP::methods, line 43

by ted.byers (Scribe)
on Sep 25, 2011 at 01:46 UTC ( #927698=perlquestion: print w/ replies, xml ) Need Help??
ted.byers has asked for the wisdom of the Perl Monks concerning the following question:

The title is the error message I find in the apache error logs.

What is especially odd is that there are two different cgi scripts that do basically the same thing, but one works and the other gives this error.

You can even check out the behaviour of the two scripts at these two URLS:

http://74.15.160.240:8080/cgi-bin/Aresults.cgi http://74.15.160.240:8080/cgi-bin/calculator.cgi

The following code producs the error in the title

sub print_response { unless ($query->param) { print "<b>Results</b>"; return; } $ticker = $query->param('ticker'); $begin_dt = $query->param('begin_dt'); $end_dt = $query->param('end_dt'); print "<b>FIRST:<br />Ticker: $ticker<br />Start date: $begin_dt<b +r />End date: $end_dt</b><br /><br />"; use Net::HTTP; print "<b>SECOND:<br />Ticker: $ticker<br />Start date: $begin_dt< +br />End date: $end_dt</b>"; my $s = Net::HTTP->new(HOST => "localhost:5000"); print "<b>THIRD:<br />Ticker: $ticker<br />Start date: $begin_dt<b +r />End date: $end_dt</b>"; $s->write_request(GET => "/Aresult.pl?ticker=$ticker&begin_dt=$beg +in_dt&end_dt=$end_dt", 'User-Agent' => "Mozilla/5.0"); ($code,$mess, %h) = $s->read_response_headers; while (1) { my $buf; my $n = $s->read_entity_body($buf,1024); last unless $n; print $buf; } }

But in the other cgi script, the following function works fine.

sub print_response { unless ($query->param) { print "<b>No data has been submitted</b>"; return; } $vdate = $query->param('vdate'); $edate = $query->param('edate'); $ot = $query->param('ot'); $ul = $query->param('underlying'); $strike = $query->param('strike'); $dy = $query->param('dividendyield'); $rfr = $query->param('riskfreerate'); $vol = $query->param('volatility'); use Net::HTTP; my $s = Net::HTTP->new(Host => "localhost:5000"); #my $s = Net::HTTP->new(Host => "192.168.2.104:5000"); $s->write_request(GET => "/calc.pl?&vdate=$vdate&edate=$edate&optionty +pe=$ot&underlying=$ul&strike=$strike&dividendyield=$dy&riskfreerate=$ +rfr&vol=$vol", 'User-Agent' => "Mozilla/5.0"); my ($code,$mess, %h) = $s->read_response_headers; while (1) { my $buf; my $n = $s->read_entity_body($buf,1024); last unless $n; print $buf; } }

Apart from the name of the cgi scripts containing these two functions, and the details of these two functions, the scripts are mostly the same.

The scripts are on the same machine, on the same instance of Apache's httpd (the latest version build for Windows - and I use the latest version of Activestate's Perl)

What can possibly account for the difference int he behvaiour of these two functions.

Comment on No Host Option provided in Net::HTTP::methods, line 43
Select or Download Code
Re: No Host Option provided in Net::HTTP::methods, line 43
by zwon (Monsignor) on Sep 25, 2011 at 03:34 UTC

    Note, that HOST is not the same as Host.

      Thanks zwon. That was it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://927698]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2014-07-29 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls