Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into hotfix/translator-caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 58 deletions.
23 changes: 17 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function setUri($uri)
/**
* Get uri (from the request)
*
* @return Zend\Uri\Http
* @return Http
*/
public function getUri()
{
Expand Down Expand Up @@ -449,13 +449,14 @@ protected function getCookieId($cookie)
*
* @param array|ArrayIterator|Header\SetCookie|string $cookie
* @param string $value
* @param string $version
* @param string $maxAge
* @param string $domain
* @param string $expire
* @param string $path
* @param string $domain
* @param boolean $secure
* @param boolean $httponly
* @param string $maxAge
* @param string $version
* @throws Exception\InvalidArgumentException
* @return Client
*/
public function addCookie($cookie, $value = null, $expire = null, $path = null, $domain = null, $secure = false, $httponly = true, $maxAge = null, $version = null)
Expand Down Expand Up @@ -483,6 +484,7 @@ public function addCookie($cookie, $value = null, $expire = null, $path = null,
* Set an array of cookies
*
* @param array $cookies
* @throws Exception\InvalidArgumentException
* @return Client
*/
public function setCookies($cookies)
Expand Down Expand Up @@ -510,6 +512,7 @@ public function clearCookies()
* Set the headers (for the request)
*
* @param Headers|array $headers
* @throws Exception\InvalidArgumentException
* @return Client
*/
public function setHeaders($headers)
Expand Down Expand Up @@ -585,6 +588,7 @@ public function getStream()
/**
* Create temporary stream
*
* @throws Exception\RuntimeException
* @return resource
*/
protected function openTempStream()
Expand Down Expand Up @@ -619,6 +623,7 @@ protected function openTempStream()
* @param string $user
* @param string $password
* @param string $type
* @throws Exception\InvalidArgumentException
* @return Client
*/
public function setAuth($user, $password, $type = self::AUTH_BASIC)
Expand Down Expand Up @@ -648,6 +653,8 @@ public function setAuth($user, $password, $type = self::AUTH_BASIC)
* @param string $password
* @param string $type
* @param array $digest
* @param null|string $entityBody
* @throws Exception\InvalidArgumentException
* @return string|boolean
*/
protected function calcAuthDigest($user, $password, $type = self::AUTH_BASIC, $digest = array(), $entityBody = null)
Expand Down Expand Up @@ -737,6 +744,7 @@ public function dispatch(Stdlib\RequestInterface $request, Stdlib\ResponseInterf
* @param Request $request
* @return Response
* @throws Exception\RuntimeException
* @throws Client\Exception\RuntimeException
*/
public function send(Request $request = null)
{
Expand Down Expand Up @@ -970,8 +978,8 @@ public function removeFileUpload($filename)
/**
* Prepare Cookies
*
* @param string $uri
* @param string $domain
* @param string $path
* @param boolean $secure
* @return Header\Cookie|boolean
*/
Expand Down Expand Up @@ -1002,6 +1010,9 @@ protected function prepareCookies($domain, $path, $secure)
/**
* Prepare the request headers
*
* @param resource|string $body
* @param Http $uri
* @throws Exception\RuntimeException
* @return array
*/
protected function prepareHeaders($body, $uri)
Expand Down Expand Up @@ -1125,7 +1136,7 @@ protected function prepareBody()
}

// Encode files
foreach ($this->getRequest()->getFiles()->toArray() as $key => $file) {
foreach ($this->getRequest()->getFiles()->toArray() as $file) {
$fhead = array('Content-Type' => $file['ctype']);
$body .= $this->encodeFormData($boundary, $file['formname'], $file['data'], $file['filename'], $fhead);
}
Expand Down
5 changes: 3 additions & 2 deletions src/Client/Adapter/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function setOptions($options = array())
}

if (isset($options['proxyuser']) && isset($options['proxypass'])) {
$this->setCurlOption(CURLOPT_PROXYUSERPWD, $options['proxyuser'].":".$options['proxypass']);
$this->setCurlOption(CURLOPT_PROXYUSERPWD, $options['proxyuser'] . ":" . $options['proxypass']);
unset($options['proxyuser'], $options['proxypass']);
}

Expand Down Expand Up @@ -213,7 +213,7 @@ public function connect($host, $port = 80, $secure = false)
if (!$this->curl) {
$this->close();

throw new AdapterException\RuntimeException('Unable to Connect to ' . $host . ':' . $port);
throw new AdapterException\RuntimeException('Unable to Connect to ' . $host . ':' . $port);
}

if ($secure !== false) {
Expand All @@ -240,6 +240,7 @@ public function connect($host, $port = 80, $secure = false)
* @param string $body
* @return string $request
* @throws AdapterException\RuntimeException If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option
* @throws AdapterException\InvalidArgumentException if $method is currently not supported
*/
public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $body = '')
{
Expand Down
2 changes: 2 additions & 0 deletions src/Client/Adapter/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function connect($host, $port = 80, $secure = false)
* @param string $http_ver
* @param array $headers
* @param string $body
* @throws AdapterException\RuntimeException
* @return string Request as string
*/
public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
Expand Down Expand Up @@ -179,6 +180,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
* @param integer $port
* @param string $http_ver
* @param array $headers
* @throws AdapterException\RuntimeException
*/
protected function connectHandshake($host, $port = 443, $http_ver = '1.1', array &$headers = array())
{
Expand Down
6 changes: 5 additions & 1 deletion src/Client/Adapter/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function __construct()
* Set the configuration array for the adapter
*
* @param array|Traversable $options
* @throws AdapterException\InvalidArgumentException
*/
public function setOptions($options = array())
{
Expand Down Expand Up @@ -140,6 +141,7 @@ public function getConfig()
* @since Zend Framework 1.9
*
* @param mixed $context Stream context or array of context options
* @throws Exception\InvalidArgumentException
* @return Socket
*/
public function setStreamContext($context)
Expand Down Expand Up @@ -252,7 +254,7 @@ public function connect($host, $port = 80, $secure = false)
'Unable to connect to %s:%d%s',
$host,
$port,
($error ? '. Error #' . $error->getCode() . ': ' . $error->getMessage() : '')
($error ? ' . Error #' . $error->getCode() . ': ' . $error->getMessage() : '')
),
0,
$error
Expand Down Expand Up @@ -319,6 +321,7 @@ public function connect($host, $port = 80, $secure = false)
* @param string $http_ver
* @param array $headers
* @param string $body
* @throws AdapterException\RuntimeException
* @return string Request as string
*/
public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
Expand Down Expand Up @@ -373,6 +376,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
/**
* Read response from server
*
* @throws AdapterException\RuntimeException
* @return string
*/
public function read()
Expand Down
4 changes: 3 additions & 1 deletion src/Client/Adapter/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function setNextRequestWillFail($flag)
* Set the configuration array for the adapter
*
* @param array|Traversable $options
* @throws Exception\InvalidArgumentException
*/
public function setOptions($options = array())
{
Expand Down Expand Up @@ -189,7 +190,7 @@ public function setResponse($response)
/**
* Add another response to the response buffer.
*
* @param string \Zend\Http\Response|$response
* @param string|Response $response
*/
public function addResponse($response)
{
Expand All @@ -205,6 +206,7 @@ public function addResponse($response)
* response will be returned on the next call to read().
*
* @param integer $index
* @throws Exception\OutOfRangeException
*/
public function setResponseIndex($index)
{
Expand Down
6 changes: 4 additions & 2 deletions src/Client/Cookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use ArrayIterator;
use Zend\Http\Header\Cookie;
use Zend\Http\Response;
use Zend\Stdlib\ParametersInterface;
use Zend\Uri;

/**
Expand Down Expand Up @@ -96,6 +95,7 @@ public function __construct()
*
* @param Cookie|string $cookie
* @param Uri\Uri|string $ref_uri Optional reference URI (for domain, path, secure)
* @throws Exception\InvalidArgumentException if invalid $cookie value
*/
public function addCookie($cookie, $ref_uri = null)
{
Expand Down Expand Up @@ -159,6 +159,7 @@ public function getAllCookies($ret_as = self::COOKIE_OBJECT)
* @param boolean $matchSessionCookies Whether to send session cookies
* @param int $ret_as Whether to return cookies as objects of \Zend\Http\Header\Cookie or as strings
* @param int $now Override the current time when checking for expiry time
* @throws Exception\InvalidArgumentException if invalid URI
* @return array|string
*/
public function getMatchingCookies($uri, $matchSessionCookies = true,
Expand Down Expand Up @@ -198,6 +199,7 @@ public function getMatchingCookies($uri, $matchSessionCookies = true,
* @param Uri\Uri|string $uri The uri (domain and path) to match
* @param string $cookie_name The cookie's name
* @param int $ret_as Whether to return cookies as objects of \Zend\Http\Header\Cookie or as strings
* @throws Exception\InvalidArgumentException if invalid URI specified or invalid $ret_as value
* @return Cookie|string
*/
public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT)
Expand Down Expand Up @@ -302,7 +304,7 @@ protected function _matchDomain($domain)
/**
* Return a subset of a domain-matching cookies that also match a specified path
*
* @param array $dom_array
* @param array $domains
* @param string $path
* @return array
*/
Expand Down
10 changes: 7 additions & 3 deletions src/ClientStatic.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ClientStatic
/**
* Get the static HTTP client
*
* @return Zend\Http\Client
* @return Client
*/
protected static function getStaticClient()
{
Expand All @@ -42,9 +42,10 @@ protected static function getStaticClient()
* @param string $url
* @param array $query
* @param array $headers
* @param mixed $body
* @return Response|boolean
*/
public static function get($url, $query=array(), $headers=array(), $body=null)
public static function get($url, $query = array(), $headers = array(), $body = null)
{
if (empty($url)) {
return false;
Expand All @@ -68,15 +69,18 @@ public static function get($url, $query=array(), $headers=array(), $body=null)

return self::getStaticClient()->send($request);
}

/**
* HTTP POST METHOD (static)
*
* @param string $url
* @param array $params
* @param array $headers
* @param mixed $body
* @throws Exception\InvalidArgumentException
* @return Response|boolean
*/
public static function post($url, $params, $headers=array(), $body=null)
public static function post($url, $params, $headers = array(), $body = null)
{
if (empty($url)) {
return false;
Expand Down
11 changes: 7 additions & 4 deletions src/Cookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
class Cookies extends Headers
{
/**
* @var Headers
* @var \Zend\Http\Headers
*/
protected $headers = null;

/**
* @var $_rawCookies
* @var array
*/
protected $rawCookies;

Expand Down Expand Up @@ -73,6 +73,7 @@ public function __construct(Headers $headers, $context = self::CONTEXT_REQUEST)
*
* @param Cookie|string $cookie
* @param Uri\Uri|string $ref_uri Optional reference URI (for domain, path, secure)
* @throws Exception\InvalidArgumentException
*/
public function addCookie(Cookie $cookie, $ref_uri = null)
{
Expand Down Expand Up @@ -136,6 +137,7 @@ public function getAllCookies($ret_as = self::COOKIE_OBJECT)
* @param boolean $matchSessionCookies Whether to send session cookies
* @param int $ret_as Whether to return cookies as objects of \Zend\Http\Header\Cookie or as strings
* @param int $now Override the current time when checking for expiry time
* @throws Exception\InvalidArgumentException if invalid URI specified
* @return array|string
*/
public function getMatchingCookies($uri, $matchSessionCookies = true,
Expand Down Expand Up @@ -175,6 +177,7 @@ public function getMatchingCookies($uri, $matchSessionCookies = true,
* @param Uri\Uri|string $uri The uri (domain and path) to match
* @param string $cookie_name The cookie's name
* @param int $ret_as Whether to return cookies as objects of \Zend\Http\Header\Cookie or as strings
* @throws Exception\InvalidArgumentException if invalid URI specified or invalid $ret_as value
* @return Cookie|string
*/
public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT)
Expand Down Expand Up @@ -279,7 +282,7 @@ protected function _matchDomain($domain)
/**
* Return a subset of a domain-matching cookies that also match a specified path
*
* @param array $dom_array
* @param array $domains
* @param string $path
* @return array
*/
Expand Down Expand Up @@ -309,7 +312,7 @@ protected function _matchPath($domains, $path)
* of the cookie.
*
* @param Response $response HTTP Response object
* @param Uri\Uri|string $uri The requested URI
* @param Uri\Uri|string $ref_uri The requested URI
* @return Cookies
* @todo Add the $uri functionality.
*/
Expand Down
Loading

0 comments on commit fd53447

Please sign in to comment.