[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Perl HTTP Utilities
Section 65 out of 79 total sections , Section 2 out of 5 sections in this chapter


HTTPConnect()


Description

HTTPConnect() connects a specified URL to a socket. It reads the HTTP status line but leaves the rest of the output. HTTPConnect() handles up to five redirects. If it doesn't load the specified URL after the fifth redirect, it fails, returning 0. As an option, you can specify the request method, GET or POST. If the method is POST, the last parameter is the content to send to the server. If you do not specify a method, GET is assumed.


Synopsis


Arguments

Argument  Meaning  
$fh  

A file(socket) handle to create. 

$url  

The URL to use, of the form http://[host[:port]]/[path].  

$method  

The request method (optional).  

$postArgs  

Args for the POST method (optional).  


Returns

Value  Meaning  
0  

Failure.  

1  

Success.  


Example

The following code retrieves the current temperature for Elko, Nevada, and generates the HDML to display it as shown in Figure 12-1:

FIGURE  12-1.     Display card with the current temperatures for Stateline.


[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Perl HTTP Utilities
Section 65 out of 79 total sections , Section 2 out of 5 sections in this chapter


Copyright © 1999, Unwired Planet, Inc. All rights reserved.