Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

by ted.byers (Monk)
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:

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 => "/$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 => ""); $s->write_request(GET => "/$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.

Replies are listed 'Best First'.
Re: No Host Option provided in Net::HTTP::methods, line 43
by zwon (Abbot) on Sep 25, 2011 at 03:34 UTC

    Note, that HOST is not the same as Host.

      Thanks zwon. That was it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://927698]
Approved by GrandFather
[Discipulus]: you are almoste there..retry ;=)
[Tux]: Hmm, that must be something in pm_cb_g
[Tux]: in the dialog area it shows correct, but the url is broken in the CB
[Discipulus]: you still need to put href:// , no?
[Tux]: [htps://metacpan. org/source/ MLEHMANN/Canary- Stability-2012/| this] is the same link posted on the PM side inside the CB
[Discipulus]: and you wrote ttps and then htps
[Tux]: new try
[Tux]: \o/ (sorry for the noise)
[Discipulus]: anyway, i'm more interested about the general idea: you (and others) do not install modules by this guy. Rigth?
[Tux]: correct

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2017-09-20 07:26 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (234 votes). Check out past polls.