3 * PHP HTTP Tools is a library for working with the http protocol
4 * php_http_connector establishes http connections
5 * @package php-http-tools
7 * @copyright (C) 2004 John Heinstein. All rights reserved
8 * @license http://www.gnu.org/copyleft/lesser.html LGPL License
9 * @author John Heinstein <johnkarl@nbnet.nb.ca>
10 * @link http://www.engageinteractive.com/php_http_tools/ PHP HTTP Tools Home Page
11 * PHP HTTP Tools are Free Software
14 if (!defined('PHP_HTTP_TOOLS_INCLUDE_PATH')) {
15 define('PHP_HTTP_TOOLS_INCLUDE_PATH', (dirname(__FILE__
) . "/"));
19 * A helper class for establishing HTTP connections
21 * @package php-http-tools
22 * @author John Heinstein <johnkarl@nbnet.nb.ca>
24 class php_http_connector
{
25 /** @var object A reference to a http connection or proxy, if one is required */
26 var $httpConnection = null;
29 * Specifies the parameters of the http conection used to obtain the xml data
30 * @param string The ip address or domain name of the connection
31 * @param string The path of the connection
32 * @param int The port that the connection is listening on
33 * @param int The timeout value for the connection
34 * @param string The user name, if authentication is required
35 * @param string The password, if authentication is required
37 function setConnection($host, $path = '/', $port = 80, $timeout = 0, $user = null, $password = null) {
38 require_once(PHP_HTTP_TOOLS_INCLUDE_PATH
. 'php_http_client_generic.php');
40 $this->httpConnection
=& new php_http_client_generic($host, $path, $port, $timeout, $user, $password);
44 * Specifies basic authentication for an http connection
45 * @param string The user name
46 * @param string The password
48 function setAuthorization($user, $password) {
49 $this->httpConnection
->setAuthorization($user, $password);
53 * Specifies that a proxy is to be used to obtain the data
54 * @param string The ip address or domain name of the proxy
55 * @param string The path to the proxy
56 * @param int The port that the proxy is listening on
57 * @param int The timeout value for the connection
58 * @param string The user name, if authentication is required
59 * @param string The password, if authentication is required
61 function setProxyConnection($host, $path = '/', $port = 80, $timeout = 0, $user = null, $password = null) {
62 require_once(PHP_HTTP_TOOLS_INCLUDE_PATH
. 'php_http_proxy.php');
64 $this->httpConnection
=& new php_http_proxy($host, $path, $port, $timeout, $user, $password);
65 } //setProxyConnection
68 * Specifies basic authentication for the proxy
69 * @param string The user name
70 * @param string The password
72 function setProxyAuthorization($user, $password) {
73 $this->httpConnection
->setProxyAuthorization($user, $password);
74 } //setProxyAuthorization
75 } //php_http_connector