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

Commit

Permalink
Merge remote-tracking branch 'zf2/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 193 changed files with 4,163 additions and 2,280 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

14 changes: 0 additions & 14 deletions .travis/run-tests.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/skipped-components

This file was deleted.

61 changes: 0 additions & 61 deletions .travis/tested-components

This file was deleted.

16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zendframework/zend-http",
"description": "Zend\\Http component",
"description": "provides an easy interface for preforming Hyper-Text Transfer Protocol (HTTP) requests",
"license": "BSD-3-Clause",
"keywords": [
"zf2",
Expand All @@ -9,11 +9,11 @@
"homepage": "https://github.com/zendframework/zend-http",
"autoload": {
"psr-4": {
"Zend\\Http\\": "src/"
"Zend\\Http": "src/"
}
},
"require": {
"php": ">=5.3.23",
"php": ">=5.3.3",
"zendframework/zend-loader": "self.version",
"zendframework/zend-stdlib": "self.version",
"zendframework/zend-uri": "self.version",
Expand All @@ -25,14 +25,14 @@
"dev-develop": "2.5-dev"
}
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"satooshi/php-coveralls": "dev-master",
"phpunit/PHPUnit": "~4.0"
},
"autoload-dev": {
"psr-4": {
"ZendTest\\Http\\": "test/"
}
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"satooshi/php-coveralls": "dev-master",
"phpunit/PHPUnit": "~4.0"
}
}
72 changes: 30 additions & 42 deletions src/Client.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend\Http
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Http
*/

namespace Zend\Http;

use ArrayIterator;
use Traversable;
use Zend\Stdlib;
use Zend\Stdlib\ArrayUtils;
use ArrayIterator,
Zend\Uri\Http,
Zend\Stdlib;
use Zend\Uri\Http;

/**
* Http client
*
* @category Zend
* @package Zend\Http
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Client implements Stdlib\DispatchableInterface
{
Expand Down Expand Up @@ -135,7 +123,7 @@ class Client implements Stdlib\DispatchableInterface
*
* @var resource
*/
static protected $_fileInfoDb = null;
protected static $_fileInfoDb = null;

/**
* Constructor
Expand Down Expand Up @@ -334,7 +322,7 @@ public function setUri($uri)
*/
public function getUri()
{
return $this->getRequest()->uri();
return $this->getRequest()->getUri();
}

/**
Expand Down Expand Up @@ -415,7 +403,7 @@ public function setRawBody($body)
*/
public function setParameterPost(array $post)
{
$this->getRequest()->post()->fromArray($post);
$this->getRequest()->getPost()->fromArray($post);
return $this;
}

Expand All @@ -427,7 +415,7 @@ public function setParameterPost(array $post)
*/
public function setParameterGet(array $query)
{
$this->getRequest()->query()->fromArray($query);
$this->getRequest()->getQuery()->fromArray($query);
return $this;
}

Expand Down Expand Up @@ -545,7 +533,7 @@ public function setHeaders($headers)
*/
public function hasHeader($name)
{
$headers = $this->getRequest()->headers();
$headers = $this->getRequest()->getHeaders();

if ($headers instanceof Headers) {
return $headers->has($name);
Expand All @@ -562,7 +550,7 @@ public function hasHeader($name)
*/
public function getHeader($name)
{
$headers = $this->getRequest()->headers();
$headers = $this->getRequest()->getHeaders();

if ($headers instanceof Headers) {
if ($headers->get($name)) {
Expand Down Expand Up @@ -766,7 +754,7 @@ public function send(Request $request = null)
$uri = $this->getUri();

// query
$query = $this->getRequest()->query();
$query = $this->getRequest()->getQuery();

if (!empty($query)) {
$queryArray = $query->toArray();
Expand Down Expand Up @@ -855,17 +843,17 @@ public function send(Request $request = null)
}

// Get the cookies from response (if any)
$setCookie = $response->cookie();
$setCookie = $response->getCookie();
if (!empty($setCookie)) {
$this->addCookie($setCookie);
}

// If we got redirected, look for the Location header
if ($response->isRedirect() && ($response->headers()->has('Location'))) {
if ($response->isRedirect() && ($response->getHeaders()->has('Location'))) {

// Avoid problems with buggy servers that add whitespace at the
// end of some headers
$location = trim($response->headers()->get('Location')->getFieldValue());
$location = trim($response->getHeaders()->get('Location')->getFieldValue());

// Check whether we send the exact same request again, or drop the parameters
// and send a GET request
Expand Down Expand Up @@ -946,7 +934,7 @@ public function setFileUpload($filename, $formname, $data = null, $ctype = null)
}
}

$this->getRequest()->file()->set($filename, array(
$this->getRequest()->getFile()->set($filename, array(
'formname' => $formname,
'filename' => basename($filename),
'ctype' => $ctype,
Expand All @@ -964,9 +952,9 @@ public function setFileUpload($filename, $formname, $data = null, $ctype = null)
*/
public function removeFileUpload($filename)
{
$file = $this->getRequest()->file()->get($filename);
$file = $this->getRequest()->getFile()->get($filename);
if (!empty($file)) {
$this->getRequest()->file()->set($filename, null);
$this->getRequest()->getFile()->set($filename, null);
return true;
}
return false;
Expand Down Expand Up @@ -1026,7 +1014,7 @@ protected function prepareHeaders($body, $uri)
}

// Set the connection header
if (!$this->getRequest()->headers()->has('Connection')) {
if (!$this->getRequest()->getHeaders()->has('Connection')) {
if (!$this->config['keepalive']) {
$headers['Connection'] = 'close';
}
Expand All @@ -1044,7 +1032,7 @@ protected function prepareHeaders($body, $uri)


// Set the user agent header
if (!$this->getRequest()->headers()->has('User-Agent') && isset($this->config['useragent'])) {
if (!$this->getRequest()->getHeaders()->has('User-Agent') && isset($this->config['useragent'])) {
$headers['User-Agent'] = $this->config['useragent'];
}

Expand Down Expand Up @@ -1078,7 +1066,7 @@ protected function prepareHeaders($body, $uri)
}

// Merge the headers of the request (if any)
$requestHeaders = $this->getRequest()->headers()->toArray();
$requestHeaders = $this->getRequest()->getHeaders()->toArray();
foreach ($requestHeaders as $key => $value) {
$headers[$key] = $value;
}
Expand Down Expand Up @@ -1107,8 +1095,8 @@ protected function prepareBody()
$body = '';
$totalFiles = 0;

if (!$this->getRequest()->headers()->has('Content-Type')) {
$totalFiles = count($this->getRequest()->file()->toArray());
if (!$this->getRequest()->getHeaders()->has('Content-Type')) {
$totalFiles = count($this->getRequest()->getFile()->toArray());
// If we have files to upload, force encType to multipart/form-data
if ($totalFiles > 0) {
$this->setEncType(self::ENC_FORMDATA);
Expand All @@ -1118,26 +1106,26 @@ protected function prepareBody()
}

// If we have POST parameters or files, encode and add them to the body
if (count($this->getRequest()->post()->toArray()) > 0 || $totalFiles > 0) {
if (count($this->getRequest()->getPost()->toArray()) > 0 || $totalFiles > 0) {
if (stripos($this->getEncType(), self::ENC_FORMDATA) === 0) {
$boundary = '---ZENDHTTPCLIENT-' . md5(microtime());
$this->setEncType(self::ENC_FORMDATA, $boundary);

// Get POST parameters and encode them
$params = self::flattenParametersArray($this->getRequest()->post()->toArray());
$params = self::flattenParametersArray($this->getRequest()->getPost()->toArray());
foreach ($params as $pp) {
$body .= $this->encodeFormData($boundary, $pp[0], $pp[1]);
}

// Encode files
foreach ($this->getRequest()->file()->toArray() as $key => $file) {
foreach ($this->getRequest()->getFile()->toArray() as $key => $file) {
$fhead = array('Content-Type' => $file['ctype']);
$body .= $this->encodeFormData($boundary, $file['formname'], $file['data'], $file['filename'], $fhead);
}
$body .= "--{$boundary}--\r\n";
} elseif (stripos($this->getEncType(), self::ENC_URLENCODED) === 0) {
// Encode body as application/x-www-form-urlencoded
$body = http_build_query($this->getRequest()->post()->toArray());
$body = http_build_query($this->getRequest()->getPost()->toArray());
} else {
throw new Client\Exception\RuntimeException("Cannot handle content type '{$this->encType}' automatically");
}
Expand Down
23 changes: 5 additions & 18 deletions src/Client/Adapter/AdapterInterface.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Http
* @subpackage Client_Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Http
*/

namespace Zend\Http\Client\Adapter;
Expand All @@ -30,8 +19,6 @@
* @category Zend
* @package Zend_Http
* @subpackage Client_Adapter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface AdapterInterface
{
Expand Down
Loading

0 comments on commit 96e9a1e

Please sign in to comment.