Skip to content

Commit

Permalink
Merge branch 'master' of ssh://dev.horde.org/horde/git/horde
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Mar 4, 2015
2 parents 46e341d + 1519353 commit 0e0d230
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 56 deletions.
109 changes: 64 additions & 45 deletions framework/Http/lib/Horde/Http/Client.php
Expand Up @@ -15,6 +15,48 @@
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package Http
*
* @property boolean $httpMethodOverride
* @see $_httpMethodOverride
* @property Horde_Http_Request_Base $request
* A concrete request instance.
* @property-write string|Horde_Url $request.uri
* Default URI if not specified for individual
* requests.
* @property-write array $request.headers
* Hash with additional request headers.
* @property-write string $request.method
* Default request method if not specified for
* individual requests.
* @property-write array|string $request.data
* POST data fields or POST/PUT data body.
* @property-write string $request.username
* Authentication user name.
* @property-write string $request.password
* Authentication password.
* @property-write string $request.authenticationScheme
* Authentication method, one of the
* Horde_Http::AUTH_* constants.
* @property-write string $request.proxyServer
* Host name of a proxy server.
* @property-write integer $request.proxyPort
* Port number of a proxy server.
* @property-write integer $request.proxyType
* Proxy server type, one of the
* Horde_Http::PROXY_* constants.
* @property-write string $request.proxyUsername
* Proxy authentication user name.
* @property-write string $request.proxyPassword
* Proxy authentication password.
* @property-write string $request.proxyAuthenticationScheme
* Proxy authentication method, one of the
* Horde_Http::AUTH_* constants.
* @property-write integer $request.redirects
* Maximum number of redirects to follow.
* @property-write integer $request.timeout
* Timeout in seconds.
* @property-write boolean $request.verifyPeer
* Verify SSL peer certificates?
*/
class Horde_Http_Client
{
Expand Down Expand Up @@ -51,41 +93,8 @@ class Horde_Http_Client
* Horde_Http_Client constructor.
*
* @param array $args Any Http_Client settings to initialize in the
* constructor. Available settings are:
* - client.httpMethodOverride: (boolean) @see
* $_httpMethodOverride
* - request: (array) See below for possible hash keys.
* - request.uri (string) Default URI if not specified
* for individual requests.
* - request.headers: (array) Hash with additional
* request headers.
* - request.method: (string) Default request method if
* not specified for individual requests.
* - request.data: (array|string) POST data fields or
* POST/PUT data body.
* - request.username: (string) Authentication user name.
* - request.password: (string) Authentication password.
* - request.authenticationScheme: (string)
* Authentication method, one of the
* Horde_Http::AUTH_* constants.
* - request.proxyServer: (string) Host name of a proxy
* server.
* - request.proxyPort: (integer) Port number of a proxy
* server.
* - request.proxyType: (integer) Proxy server type, one
* of the Horde_Http::PROXY_* constants.
* - request.proxyUsername: (string) Proxy authentication
* user name.
* - request.proxyPassword: (string) Proxy authentication
* password.
* - request.proxyAuthenticationScheme: (string) Proxy
* authentication method, one of the
* Horde_Http::AUTH_* constants.
* - request.redirects: (integer) Maximum number of
* redirects to follow.
* - request.timeout: (integer) Timeout in seconds.
* - request.verifyPeer: (boolean) Verify SSL peer
* certificates?
* constructor. See the class properties for available
* settings.
*/
public function __construct($args = array())
{
Expand Down Expand Up @@ -145,7 +154,10 @@ public function post($uri = null, $data = null, $headers = array())
public function put($uri = null, $data = null, $headers = array())
{
if ($this->_httpMethodOverride) {
$headers = array_merge(array('X-HTTP-Method-Override' => 'PUT'), $headers);
$headers = array_merge(
array('X-HTTP-Method-Override' => 'PUT'),
$headers
);
return $this->post($uri, $data, $headers);
}

Expand All @@ -164,7 +176,10 @@ public function put($uri = null, $data = null, $headers = array())
public function delete($uri = null, $headers = array())
{
if ($this->_httpMethodOverride) {
$headers = array_merge(array('X-HTTP-Method-Override' => 'DELETE'), $headers);
$headers = array_merge(
array('X-HTTP-Method-Override' => 'DELETE'),
$headers
);
return $this->post($uri, null, $headers);
}

Expand All @@ -188,18 +203,22 @@ public function head($uri = null, $headers = array())
/**
* Sends an HTTP request.
*
* @param string $method HTTP request method (GET, PUT, etc.)
* @param string $uri URI to request, if different from $this->uri
* @param mixed $data Request data. Can be an array of form data that
* will be encoded automatically, or a raw string.
* @param array $headers Any headers specific to this request. They will
* be combined with $this->_headers, and override
* headers of the same name for this request only.
* @param string $method HTTP request method (GET, PUT, etc.)
* @param string|Horde_Url $uri URI to request, if different from
* $this->uri
* @param string|array $data Request data. Array of form data that will
* be encoded automatically, or a raw string.
* @param array $headers Any headers specific to this request. They
* will be combined with $this->_headers, and
* override headers of the same name for this
* request only.
*
* @throws Horde_Http_Exception
* @return Horde_Http_Response_Base
*/
public function request($method, $uri = null, $data = null, $headers = array())
public function request(
$method, $uri = null, $data = null, $headers = array()
)
{
if ($method !== null) {
$this->request->method = $method;
Expand Down
22 changes: 22 additions & 0 deletions framework/Http/lib/Horde/Http/Request/Base.php
Expand Up @@ -13,6 +13,28 @@
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package Http
*
* @property string|Horde_Url $uri Default URI if not specified for
* individual requests.
* @property array $headers Hash with additional request headers.
* @property string $method Default request method if not specified
* for individual requests.
* @property array|string $data POST data fields or POST/PUT data body.
* @property string $username Authentication user name.
* @property string $password Authentication password.
* @property string $authenticationScheme Authentication method, one of the
* Horde_Http::AUTH_* constants.
* @property string $proxyServer Host name of a proxy server.
* @property integer $proxyPort Port number of a proxy server.
* @property integer $proxyType Proxy server type, one of the
* Horde_Http::PROXY_* constants.
* @property string $proxyUsername Proxy authentication user name.
* @property string $proxyPassword Proxy authentication password.
* @property string $proxyAuthenticationScheme Proxy authentication method,
* one of the Horde_Http::AUTH_* constants.
* @property integer $redirects Maximum number of redirects to follow.
* @property integer $timeout Timeout in seconds.
* @property boolean $verifyPeer Verify SSL peer certificates?
*/
abstract class Horde_Http_Request_Base
{
Expand Down
4 changes: 2 additions & 2 deletions framework/Http/lib/Horde/Http/Request/Curl.php
Expand Up @@ -53,7 +53,7 @@ public function __construct($args = array())
public function send()
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->uri);
curl_setopt($curl, CURLOPT_URL, (string)$this->uri);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->method);
Expand Down Expand Up @@ -123,7 +123,7 @@ public function send()
throw new Horde_Http_Exception(curl_error($curl), curl_errno($curl));
}
$info = curl_getinfo($curl);
return new Horde_Http_Response_Curl($this->uri, $result, $info);
return new Horde_Http_Response_Curl((string)$this->uri, $result, $info);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion framework/Http/lib/Horde/Http/Request/Fopen.php
Expand Up @@ -49,7 +49,7 @@ public function __construct($args = array())
public function send()
{
$method = $this->method;
$uri = $this->uri;
$uri = (string)$this->uri;
$headers = $this->headers;
$data = $this->data;
if (is_array($data)) {
Expand Down
8 changes: 5 additions & 3 deletions framework/Http/lib/Horde/Http/Request/Peclhttp.php
Expand Up @@ -17,7 +17,9 @@
class Horde_Http_Request_Peclhttp extends Horde_Http_Request_PeclhttpBase
{
/**
* Map of HTTP authentication schemes from Horde_Http constants to HTTP_AUTH constants.
* Map of HTTP authentication schemes from Horde_Http constants to
* HTTP_AUTH constants.
*
* @var array
*/
protected $_httpAuthSchemes = array(
Expand Down Expand Up @@ -54,7 +56,7 @@ public function send()
throw new Horde_Http_Exception('Method ' . $this->method . ' not supported.');
}

$httpRequest = new HttpRequest($this->uri, constant('HTTP_METH_' . $this->method));
$httpRequest = new HttpRequest((string)$this->uri, constant('HTTP_METH_' . $this->method));

$data = $this->data;
if (is_array($data)) {
Expand All @@ -79,6 +81,6 @@ public function send()
}
}

return new Horde_Http_Response_Peclhttp($this->uri, $httpResponse);
return new Horde_Http_Response_Peclhttp((string)$this->uri, $httpResponse);
}
}
8 changes: 5 additions & 3 deletions framework/Http/lib/Horde/Http/Request/Peclhttp2.php
Expand Up @@ -17,7 +17,9 @@
class Horde_Http_Request_Peclhttp2 extends Horde_Http_Request_PeclhttpBase
{
/**
* Map of HTTP authentication schemes from Horde_Http constants to HTTP_AUTH constants.
* Map of HTTP authentication schemes from Horde_Http constants to
* HTTP_AUTH constants.
*
* @var array
*/
protected $_httpAuthSchemes = array(
Expand Down Expand Up @@ -70,7 +72,7 @@ public function send()
$body->append($data);
}

$httpRequest = new \http\Client\Request($this->method, $this->uri, $this->headers, $body);
$httpRequest = new \http\Client\Request($this->method, (string)$this->uri, $this->headers, $body);

$client->setOptions($this->_httpOptions());

Expand All @@ -83,6 +85,6 @@ public function send()
throw new Horde_Http_Exception($e);
}

return new Horde_Http_Response_Peclhttp2($this->uri, $httpResponse);
return new Horde_Http_Response_Peclhttp2((string)$this->uri, $httpResponse);
}
}
4 changes: 2 additions & 2 deletions framework/Http/package.xml
Expand Up @@ -28,7 +28,7 @@
</stability>
<license uri="http://www.horde.org/licenses/bsd">BSD-2-Clause</license>
<notes>
*
* [jan] Allow to pass Horde_Url objects as URI (Bug #13897).
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -523,7 +523,7 @@
<date>2015-03-03</date>
<license uri="http://www.horde.org/licenses/bsd">BSD-2-Clause</license>
<notes>
*
* [jan] Allow to pass Horde_Url objects as URI (Bug #13897).
</notes>
</release>
</changelog>
Expand Down

0 comments on commit 0e0d230

Please sign in to comment.