Subject: | documentation ambiguous for HTTP method, bad code example in POD |
Reading the documentation for 0.084, in the introduction, it gives a
code example of
"
$INET = new Win32::Internet();
$HTTP = $INET->HTTP("www.yahoo.com", "anonymous", "dada@perl.it");
($statuscode, $headers, $file) = $HTTP->Request("/");
$HTTP->Close();
"
With the HTTP object being the return of the HTTP method.
Later on, in the documentation for the HTTP method, it gives the
prototype of the HTTP method as
"
HTTP httpobject, server, username, password, [port, flags, context]
HTTP httpobject, hashref
"
with the httpobject scalar parameter becoming the HTTP object after
executing the HTTP method.
The documentation for HTTP method also supports the httpobject as
parameter, not as return, with this code example.
"
$result =
$INET->HTTP($HTTP,"www.activeware.com","anonymous","dada\@perl.it");
# and then for example...
($statuscode, $headers, $file) = $HTTP->Request("/gifs/camel.gif");
$params{"server"} = "www.activeware.com";
$params{"password"} = "dada\@perl.it";
$params{"flags"} = INTERNET_FLAG_RELOAD;
$result = $INET->HTTP($HTTP,\%params);
"
In the code for 0.084, the HTTP method collects its parameters as
"
sub HTTP {
#=========
my($self, $new, $server, $username, $password, $port, $flags,
$context) = @_;
"
The $new scalar is never mentioned again the in the source code of HTTP
method. The source code, says the HTTP handle number is returned and
also the handle number is blessed into an object and then assigned back
by reference to $_[1], which would become the HTTP object in the method
parameters.
Also the code example in the introduction won't work,
"
$INET = new Win32::Internet();
$HTTP = $INET->HTTP("www.yahoo.com", "anonymous", "dada@perl.it");
($statuscode, $headers, $file) = $HTTP->Request("/");
$HTTP->Close();
"
I changed it to
"
use Win32::Internet;
$c = new Win32::Internet();
$HTTP = $c->HTTP("www.yahoo.com");
($statuscode, $headers, $file) = $HTTP->Request("/");
$HTTP->Close();
"
and got
"
Can't call method "Request" without a package or object reference at
C:\Documents and Settings\Owner\Desktop\w32inet.pl line 4.
"
Debugger says $HTTP is a handle number, not an object.
The code says the introduction is wrong, and the HTTP method
documentation is right. I'm not sure if the documentation is supposed to
be right and the code wrong, or the code is right and the documentation
is wrong.