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

Commit

Permalink
Merge branch 'cs/zendframework/zendframework#6971-zend-http-psr2-comp…
Browse files Browse the repository at this point in the history
…liance' into develop

Close zendframework/zendframework#6971
  • Loading branch information
Ocramius committed Dec 8, 2014
3 parents 49bd13e + 555b903 + a4aaef8 commit 249c18b
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 37 deletions.
2 changes: 0 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ public function getResponse()
return $this->response;
}


/**
* Get the last request (as a string)
*
Expand Down Expand Up @@ -940,7 +939,6 @@ public function send(Request $request = null)
$this->setMethod(Request::METHOD_GET);
}


// If we got a well formed absolute URI
if (($scheme = substr($location, 0, 6)) &&
($scheme == 'http:/' || $scheme == 'https:')) {
Expand Down
1 change: 0 additions & 1 deletion src/ClientStatic.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Zend\Http;


/**
* Http static client
*/
Expand Down
10 changes: 6 additions & 4 deletions src/Cookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Zend\Http\Header\SetCookie;
use Zend\Uri;


/**
* A Zend\Http\Cookies object is designed to contain and maintain HTTP cookies, and should
* be used along with Zend\Http\Client in order to manage cookies across HTTP requests and
Expand Down Expand Up @@ -161,9 +160,12 @@ public function getAllCookies($retAs = self::COOKIE_OBJECT)
* @throws Exception\InvalidArgumentException if invalid URI specified
* @return array|string
*/
public function getMatchingCookies($uri, $matchSessionCookies = true,
$retAs = self::COOKIE_OBJECT, $now = null)
{
public function getMatchingCookies(
$uri,
$matchSessionCookies = true,
$retAs = self::COOKIE_OBJECT,
$now = null
) {
if (is_string($uri)) {
$uri = Uri\UriFactory::factory($uri, 'http');
} elseif (!$uri instanceof Uri\Uri) {
Expand Down
3 changes: 1 addition & 2 deletions src/Exception/OutOfRangeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Zend\Http\Exception;

class OutOfRangeException extends \OutOfRangeException implements
ExceptionInterface
class OutOfRangeException extends \OutOfRangeException implements ExceptionInterface
{
}
14 changes: 5 additions & 9 deletions src/Header/AbstractAccept.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ abstract class AbstractAccept implements HeaderInterface
*/
protected $sorted = false;


/**
* Parse a full header line or just the field value part.
*
Expand Down Expand Up @@ -102,7 +101,7 @@ public function getFieldValuePartsFromHeaderLine($headerLine)
|| !isset($values[0])
) {
throw new Exception\InvalidArgumentException(
'Invalid header line for ' . $this->getFieldName() . ' header string'
'Invalid header line for ' . $this->getFieldName() . ' header string'
);
}

Expand Down Expand Up @@ -182,7 +181,6 @@ protected function getParametersFromFieldValuePart($fieldValuePart)
return $params;
}


/**
* Get field value
*
Expand All @@ -205,7 +203,6 @@ public function getFieldValue($values = null)
return implode(', ', $strings);
}


/**
* Assemble and escape the field value parameters based on RFC 2616 section 2.1
*
Expand All @@ -219,7 +216,8 @@ protected function assembleAcceptParam(&$value, $key)
$separators = array('(', ')', '<', '>', '@', ',', ';', ':',
'/', '[', ']', '?', '=', '{', '}', ' ', "\t");

$escaped = preg_replace_callback('/[[:cntrl:]"\\\\]/', // escape cntrl, ", \
$escaped = preg_replace_callback(
'/[[:cntrl:]"\\\\]/', // escape cntrl, ", \
function ($v) {
return '\\' . $v[0];
},
Expand Down Expand Up @@ -269,15 +267,14 @@ protected function addType($type, $priority = 1, array $params = array())
}

$assembledString = $this->getFieldValue(
array((object) array('typeString' => $type, 'params' => $params))
);
array((object) array('typeString' => $type, 'params' => $params))
);

$value = $this->parseFieldValuePart($assembledString);
$this->addFieldValuePartToQueue($value);
return $this;
}


/**
* Does the header have the requested type?
*
Expand Down Expand Up @@ -375,7 +372,6 @@ protected function matchAcceptParams($match1, $match2)
return $match1;
}


/**
* Add a key/value combination to the internal queue
*
Expand Down
7 changes: 3 additions & 4 deletions src/Header/AbstractLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Zend\Uri\UriFactory;
use Zend\Uri\UriInterface;


/**
* Abstract Location Header
* Supports headers that have URI as value
Expand Down Expand Up @@ -74,9 +73,9 @@ public function setUri($uri)
$uri = UriFactory::factory($uri);
} catch (UriException\InvalidUriPartException $e) {
throw new Exception\InvalidArgumentException(
sprintf('Invalid URI passed as string (%s)', (string) $uri),
$e->getCode(),
$e
sprintf('Invalid URI passed as string (%s)', (string) $uri),
$e->getCode(),
$e
);
}
} elseif (!($uri instanceof UriInterface)) {
Expand Down
2 changes: 0 additions & 2 deletions src/Header/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public static function fromString($headerLine)
return $header;
}


/**
* Set Connection header to define persistent connection
*
Expand Down Expand Up @@ -87,7 +86,6 @@ public function setValue($value)
return $this;
}


/**
* Connection header name
*
Expand Down
1 change: 0 additions & 1 deletion src/Header/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Zend\Http\Header;


/**
* Location Header
*
Expand Down
36 changes: 25 additions & 11 deletions src/Header/SetCookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,35 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false)
}

// First K=V pair is always the cookie name and value
if ($header->getName() === NULL) {
if ($header->getName() === null) {
$header->setName($headerKey);
$header->setValue(urldecode($headerValue));
continue;
}

// Process the remaining elements
switch (str_replace(array('-', '_'), '', strtolower($headerKey))) {
case 'expires' : $header->setExpires($headerValue); break;
case 'domain' : $header->setDomain($headerValue); break;
case 'path' : $header->setPath($headerValue); break;
case 'secure' : $header->setSecure(true); break;
case 'httponly': $header->setHttponly(true); break;
case 'version' : $header->setVersion((int) $headerValue); break;
case 'maxage' : $header->setMaxAge((int) $headerValue); break;
case 'expires':
$header->setExpires($headerValue);
break;
case 'domain':
$header->setDomain($headerValue);
break;
case 'path':
$header->setPath($headerValue);
break;
case 'secure':
$header->setSecure(true);
break;
case 'httponly':
$header->setHttponly(true);
break;
case 'version':
$header->setVersion((int) $headerValue);
break;
case 'maxage':
$header->setMaxAge((int) $headerValue);
break;
default:
// Intentionally omitted
}
Expand Down Expand Up @@ -210,7 +224,7 @@ public function getFieldValue()
}

$value = urlencode($this->getValue());
if ( $this->hasQuoteFieldValue() ) {
if ($this->hasQuoteFieldValue()) {
$value = '"'. $value . '"';
}

Expand Down Expand Up @@ -369,7 +383,7 @@ public function setExpires($expires)
// if $tsExpires is invalid and PHP is compiled as 32bit. Check if it fail reason is the 2038 bug
if (!is_int($tsExpires) && PHP_INT_SIZE === 4) {
$dateTime = new DateTime($expires);
if ( $dateTime->format('Y') > 2038) {
if ($dateTime->format('Y') > 2038) {
$tsExpires = PHP_INT_MAX;
}
}
Expand Down Expand Up @@ -552,7 +566,7 @@ public function isValidForRequest($requestDomain, $path, $isSecure = false)
*/
public function match($uri, $matchSessionCookies = true, $now = null)
{
if (is_string ($uri)) {
if (is_string($uri)) {
$uri = UriFactory::factory($uri);
}

Expand Down
1 change: 0 additions & 1 deletion src/PhpEnvironment/RemoteAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ protected function getIpAddressFromProxy()
return $ip;
}


/**
* Normalize a header string
*
Expand Down

0 comments on commit 249c18b

Please sign in to comment.