Fixing file upload params ($_FILES) normalization. Closes #75
[akelos.git] / vendor / domit / php_http_proxy.php
blob3a44a9ceb6a5e5bd90894a310b3db8767d8314f0
1 <?php
2 /**
3 * PHP HTTP Tools is a library for working with the http protocol
4 * php_http_proxy represents a basic http proxy
5 * @package php-http-tools
6 * @version 0.2-pre
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
12 **/
13 if (!defined('PHP_HTTP_TOOLS_INCLUDE_PATH')) {
14 define('PHP_HTTP_TOOLS_INCLUDE_PATH', (dirname(__FILE__) . "/"));
17 require_once(PHP_HTTP_TOOLS_INCLUDE_PATH . 'php_http_client_generic.php');
19 /**
20 * An HTTP Proxy class
22 * @package php-http-tools
23 * @author John Heinstein <johnkarl@nbnet.nb.ca>
25 class php_http_proxy extends php_http_client_generic {
27 /**
28 * HTTP Proxy constructor
29 * @param string The client connection host name, with or without its protocol prefix
30 * @param string The client connection path, not including the host name
31 * @param int The port to establish the client connection on
32 * @param int The timeout value for the client connection
34 function php_http_proxy($host, $path = '/', $port = 80, $timeout = 0) {
35 $this->php_http_client_generic($host, $path, $port, $timeout);
36 $this->setHeaders();
37 } //php_http_proxy
39 /**
40 * Sets the proxy timeout to the specified value
41 * @param int The timeout value for the client connection
43 function setTimeout($timeout) {
44 $this->timeout = $timeout;
45 } //setTimeout
47 /**
48 * Sets the proxy headers
50 function setHeaders() {
51 $this->setHeader('User-Agent', 'PHP-HTTP-Proxy-Client/0.1');
52 $this->setHeader('Connection', 'Close');
53 } //setHeaders
55 /**
56 * Specifies a user name and password for basic proxy authentication
57 * @param string The user name for proxy authentication
58 * @param string The password for proxy authentication
60 function setProxyAuthorization($user, $password) {
61 $encodedChallengeResponse = 'Basic ' . base64_encode($this->user . ':' . $this->password);
62 $this->setHeader('Proxy-Authorization', $encodedChallengeResponse);
63 } //setProxyAuthorization
65 /**
66 * Handler for customizing the HTTP GET call
67 * @param string The target url
69 function get_custom($filename) {
70 $url = $this->connection->formatHost($filename);
71 $sep = strpos($url, '/');
72 $targetHost = substr($url, 0, $sep);
74 $this->setHeader('Host', $targetHost);
75 } //get_custom
76 } //php_http_proxy