HTTP Proxy

  Status: implemented,  Sat Jul 5 18:59:34 2008
  • Created: 2008-04-16 20:39:56+0200
  • Categories: peer.http
  • Author: friebe
  • Contributors: ohinckel, kiesel

Scope of Change

A functionality will be added to the peer.http.HttpConnection class to support HTTP proxies.


Rationale

Some machines in restricted networks may not access other networks directly.

Functionality



API: The HttpProxy class

  class HttpProxy extends Object {

/**
* Constructor
*
* @param string host
* @param int port default 8080
*/
public function __construct($host, $port= 8080) {
// ...
}

/**
* Add a URL pattern to exclude.
*
* @param string pattern
*/
public function addExclude($pattern) {
// ...
}

/**
* Add a URL pattern to exclude and return this proxy. For use with
* chained method calls.
*
* @param string pattern
* @return peer.http.HttpProxy this object
*/
public function withExclude($pattern) {
// ...
}
}

API: The HttpConnection class

  class HttpConnection extends Object {
// ...

/**
* Set proxy
*
* @param peer.http.HttpProxy proxy
*/
public function setProxy(HttpProxy $proxy) {
// ...
}

// ...
}



Example

  $conn= new HttpConnection($url);
$conn->setProxy(create(new HttpProxy($host, $port))
->withExclude
('localhost')
->withExclude
('.example.com')
);
$response= $this->conn->get();



Security considerations

n/a

Speed impact

n/a

Dependencies

n/a

Related documents



Comments

friebe, Sun Jun 1 13:56:30 2008

I'm not really happy with the implementation, and it is not testable in an easy fashion. Since the HttpConnection class itself isn't easily testable either and accessing the request (e.g. for logging purposes) is hacky, too (can't be done until is has been sent!), maybe we should rewrite completely within this RFC (thus delaying it longer, though).

<EOF>


Table of contents