seeder-migration-issues
This commit is contained in:
456
vendor/zendframework/zend-http/src/Header/AbstractAccept.php
vendored
Normal file
456
vendor/zendframework/zend-http/src/Header/AbstractAccept.php
vendored
Normal file
@@ -0,0 +1,456 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Abstract Accept Header
|
||||
*
|
||||
* Naming conventions:
|
||||
*
|
||||
* Accept: audio/mp3; q=0.2; version=0.5, audio/basic+mp3
|
||||
* |------------------------------------------------------| header line
|
||||
* |------| field name
|
||||
* |-----------------------------------------------| field value
|
||||
* |-------------------------------| field value part
|
||||
* |------| type
|
||||
* |--| subtype
|
||||
* |--| format
|
||||
* |----| subtype
|
||||
* |---| format
|
||||
* |-------------------| parameter set
|
||||
* |-----------| parameter
|
||||
* |-----| parameter key
|
||||
* |--| parameter value
|
||||
* |---| priority
|
||||
*
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
|
||||
* @author Dolf Schimmel - Freeaqingme
|
||||
*/
|
||||
abstract class AbstractAccept implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var stdClass[]
|
||||
*/
|
||||
protected $fieldValueParts = [];
|
||||
|
||||
protected $regexAddType;
|
||||
|
||||
/**
|
||||
* Determines if since last mutation the stack was sorted
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $sorted = false;
|
||||
|
||||
/**
|
||||
* Parse a full header line or just the field value part.
|
||||
*
|
||||
* @param string $headerLine
|
||||
*/
|
||||
public function parseHeaderLine($headerLine)
|
||||
{
|
||||
if (strpos($headerLine, ':') !== false) {
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
if (strtolower($name) !== strtolower($this->getFieldName())) {
|
||||
$value = $headerLine; // This is just for preserve the BC.
|
||||
}
|
||||
} else {
|
||||
$value = $headerLine;
|
||||
}
|
||||
|
||||
HeaderValue::assertValid($value);
|
||||
|
||||
foreach ($this->getFieldValuePartsFromHeaderLine($value) as $value) {
|
||||
$this->addFieldValuePartToQueue($value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method: parse Accept header string
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @return Accept
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
$obj = new static();
|
||||
$obj->parseHeaderLine($headerLine);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the Field Value Parts represented by a header line
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @throws Exception\InvalidArgumentException If header is invalid
|
||||
* @return array
|
||||
*/
|
||||
public function getFieldValuePartsFromHeaderLine($headerLine)
|
||||
{
|
||||
// process multiple accept values, they may be between quotes
|
||||
if (!preg_match_all('/(?:[^,"]|"(?:[^\\\"]|\\\.)*")+/', $headerLine, $values)
|
||||
|| !isset($values[0])
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid header line for ' . $this->getFieldName() . ' header string'
|
||||
);
|
||||
}
|
||||
|
||||
$out = [];
|
||||
foreach ($values[0] as $value) {
|
||||
$value = trim($value);
|
||||
$out[] = $this->parseFieldValuePart($value);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the accept params belonging to a media range
|
||||
*
|
||||
* @param string $fieldValuePart
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function parseFieldValuePart($fieldValuePart)
|
||||
{
|
||||
$raw = $subtypeWhole = $type = $fieldValuePart;
|
||||
if ($pos = strpos($fieldValuePart, ';')) {
|
||||
$type = substr($fieldValuePart, 0, $pos);
|
||||
}
|
||||
|
||||
$params = $this->getParametersFromFieldValuePart($fieldValuePart);
|
||||
|
||||
if ($pos = strpos($fieldValuePart, ';')) {
|
||||
$fieldValuePart = trim(substr($fieldValuePart, 0, $pos));
|
||||
}
|
||||
|
||||
$format = '*';
|
||||
$subtype = '*';
|
||||
|
||||
return (object) [
|
||||
'typeString' => trim($fieldValuePart),
|
||||
'type' => $type,
|
||||
'subtype' => $subtype,
|
||||
'subtypeRaw' => $subtypeWhole,
|
||||
'format' => $format,
|
||||
'priority' => isset($params['q']) ? $params['q'] : 1,
|
||||
'params' => $params,
|
||||
'raw' => trim($raw)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the keys contained in the header line
|
||||
*
|
||||
* @param string $fieldValuePart
|
||||
* @return array
|
||||
*/
|
||||
protected function getParametersFromFieldValuePart($fieldValuePart)
|
||||
{
|
||||
$params = [];
|
||||
if ((($pos = strpos($fieldValuePart, ';')) !== false)) {
|
||||
preg_match_all('/(?:[^;"]|"(?:[^\\\"]|\\\.)*")+/', $fieldValuePart, $paramsStrings);
|
||||
|
||||
if (isset($paramsStrings[0])) {
|
||||
array_shift($paramsStrings[0]);
|
||||
$paramsStrings = $paramsStrings[0];
|
||||
}
|
||||
|
||||
foreach ($paramsStrings as $param) {
|
||||
$explode = explode('=', $param, 2);
|
||||
|
||||
$value = trim($explode[1]);
|
||||
if (isset($value[0]) && $value[0] == '"' && substr($value, -1) == '"') {
|
||||
$value = substr(substr($value, 1), 0, -1);
|
||||
}
|
||||
|
||||
$params[trim($explode[0])] = stripslashes($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get field value
|
||||
*
|
||||
* @param array|null $values
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue($values = null)
|
||||
{
|
||||
if (!$values) {
|
||||
return $this->getFieldValue($this->fieldValueParts);
|
||||
}
|
||||
|
||||
$strings = [];
|
||||
foreach ($values as $value) {
|
||||
$params = $value->params;
|
||||
array_walk($params, [$this, 'assembleAcceptParam']);
|
||||
$strings[] = implode(';', [$value->typeString] + $params);
|
||||
}
|
||||
|
||||
return implode(', ', $strings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assemble and escape the field value parameters based on RFC 2616 section 2.1
|
||||
*
|
||||
* @todo someone should review this thoroughly
|
||||
* @param string $value
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
protected function assembleAcceptParam(&$value, $key)
|
||||
{
|
||||
$separators = ['(', ')', '<', '>', '@', ',', ';', ':',
|
||||
'/', '[', ']', '?', '=', '{', '}', ' ', "\t"];
|
||||
|
||||
$escaped = preg_replace_callback(
|
||||
'/[[:cntrl:]"\\\\]/', // escape cntrl, ", \
|
||||
function ($v) {
|
||||
return '\\' . $v[0];
|
||||
},
|
||||
$value
|
||||
);
|
||||
|
||||
if ($escaped == $value && !array_intersect(str_split($value), $separators)) {
|
||||
$value = $key . '=' . $value;
|
||||
} else {
|
||||
$value = $key . '="' . $escaped . '"';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a type, with the given priority
|
||||
*
|
||||
* @param string $type
|
||||
* @param int|float $priority
|
||||
* @param array (optional) $params
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return Accept
|
||||
*/
|
||||
protected function addType($type, $priority = 1, array $params = [])
|
||||
{
|
||||
if (!preg_match($this->regexAddType, $type)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects a valid type; received "%s"',
|
||||
__METHOD__,
|
||||
(string) $type
|
||||
));
|
||||
}
|
||||
|
||||
if (!is_int($priority) && !is_float($priority) && !is_numeric($priority)
|
||||
|| $priority > 1 || $priority < 0
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects a numeric priority; received %s',
|
||||
__METHOD__,
|
||||
(string) $priority
|
||||
));
|
||||
}
|
||||
|
||||
if ($priority != 1) {
|
||||
$params = ['q' => sprintf('%01.1f', $priority)] + $params;
|
||||
}
|
||||
|
||||
$assembledString = $this->getFieldValue(
|
||||
[(object) ['typeString' => $type, 'params' => $params]]
|
||||
);
|
||||
|
||||
$value = $this->parseFieldValuePart($assembledString);
|
||||
$this->addFieldValuePartToQueue($value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the header have the requested type?
|
||||
*
|
||||
* @param array|string $matchAgainst
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasType($matchAgainst)
|
||||
{
|
||||
return (bool) $this->match($matchAgainst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Match a media string against this header
|
||||
*
|
||||
* @param array|string $matchAgainst
|
||||
* @return Accept\FieldValuePArt\AcceptFieldValuePart|bool The matched value or false
|
||||
*/
|
||||
public function match($matchAgainst)
|
||||
{
|
||||
if (is_string($matchAgainst)) {
|
||||
$matchAgainst = $this->getFieldValuePartsFromHeaderLine($matchAgainst);
|
||||
}
|
||||
|
||||
foreach ($this->getPrioritized() as $left) {
|
||||
foreach ($matchAgainst as $right) {
|
||||
if ($right->type == '*' || $left->type == '*') {
|
||||
if ($this->matchAcceptParams($left, $right)) {
|
||||
$left->setMatchedAgainst($right);
|
||||
|
||||
return $left;
|
||||
}
|
||||
}
|
||||
|
||||
if ($left->type == $right->type) {
|
||||
if (($left->subtype == $right->subtype || ($right->subtype == '*' || $left->subtype == '*')) &&
|
||||
($left->format == $right->format || $right->format == '*' || $left->format == '*')
|
||||
) {
|
||||
if ($this->matchAcceptParams($left, $right)) {
|
||||
$left->setMatchedAgainst($right);
|
||||
|
||||
return $left;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a match where all parameters in argument #1 match those in argument #2
|
||||
*
|
||||
* @param array $match1
|
||||
* @param array $match2
|
||||
* @return bool|array
|
||||
*/
|
||||
protected function matchAcceptParams($match1, $match2)
|
||||
{
|
||||
foreach ($match2->params as $key => $value) {
|
||||
if (isset($match1->params[$key])) {
|
||||
if (strpos($value, '-')) {
|
||||
preg_match(
|
||||
'/^(?|([^"-]*)|"([^"]*)")-(?|([^"-]*)|"([^"]*)")\z/',
|
||||
$value,
|
||||
$pieces
|
||||
);
|
||||
|
||||
if (count($pieces) == 3 &&
|
||||
(version_compare($pieces[1], $match1->params[$key], '<=') xor
|
||||
version_compare($pieces[2], $match1->params[$key], '>=')
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
} elseif (strpos($value, '|')) {
|
||||
$options = explode('|', $value);
|
||||
$good = false;
|
||||
foreach ($options as $option) {
|
||||
if ($option == $match1->params[$key]) {
|
||||
$good = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$good) {
|
||||
return false;
|
||||
}
|
||||
} elseif ($match1->params[$key] != $value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $match1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a key/value combination to the internal queue
|
||||
*
|
||||
* @param stdClass $value
|
||||
* @return number
|
||||
*/
|
||||
protected function addFieldValuePartToQueue($value)
|
||||
{
|
||||
$this->fieldValueParts[] = $value;
|
||||
$this->sorted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the internal Field Value Parts
|
||||
*
|
||||
* @See rfc2616 sect 14.1
|
||||
* Media ranges can be overridden by more specific media ranges or
|
||||
* specific media types. If more than one media range applies to a given
|
||||
* type, the most specific reference has precedence. For example,
|
||||
*
|
||||
* Accept: text/*, text/html, text/html;level=1, * /*
|
||||
*
|
||||
* have the following precedence:
|
||||
*
|
||||
* 1) text/html;level=1
|
||||
* 2) text/html
|
||||
* 3) text/*
|
||||
* 4) * /*
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
protected function sortFieldValueParts()
|
||||
{
|
||||
$sort = function ($a, $b) { // If A has higher precedence than B, return -1.
|
||||
if ($a->priority > $b->priority) {
|
||||
return -1;
|
||||
} elseif ($a->priority < $b->priority) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Asterisks
|
||||
$values = ['type', 'subtype', 'format'];
|
||||
foreach ($values as $value) {
|
||||
if ($a->$value == '*' && $b->$value != '*') {
|
||||
return 1;
|
||||
} elseif ($b->$value == '*' && $a->$value != '*') {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($a->type == 'application' && $b->type != 'application') {
|
||||
return -1;
|
||||
} elseif ($b->type == 'application' && $a->type != 'application') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//@todo count number of dots in case of type==application in subtype
|
||||
|
||||
// So far they're still the same. Longest string length may be more specific
|
||||
if (strlen($a->raw) == strlen($b->raw)) {
|
||||
return 0;
|
||||
}
|
||||
return (strlen($a->raw) > strlen($b->raw)) ? -1 : 1;
|
||||
};
|
||||
|
||||
usort($this->fieldValueParts, $sort);
|
||||
$this->sorted = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array with all the keys, values and parameters this header represents:
|
||||
*/
|
||||
public function getPrioritized()
|
||||
{
|
||||
if (!$this->sorted) {
|
||||
$this->sortFieldValueParts();
|
||||
}
|
||||
|
||||
return $this->fieldValueParts;
|
||||
}
|
||||
}
|
268
vendor/zendframework/zend-http/src/Header/AbstractDate.php
vendored
Normal file
268
vendor/zendframework/zend-http/src/Header/AbstractDate.php
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
|
||||
/**
|
||||
* Abstract Date/Time Header
|
||||
* Supports headers that have date/time as value
|
||||
*
|
||||
* @see Zend\Http\Header\Date
|
||||
* @see Zend\Http\Header\Expires
|
||||
* @see Zend\Http\Header\IfModifiedSince
|
||||
* @see Zend\Http\Header\IfUnmodifiedSince
|
||||
* @see Zend\Http\Header\LastModified
|
||||
*
|
||||
* Note for 'Location' header:
|
||||
* While RFC 1945 requires an absolute URI, most of the browsers also support relative URI
|
||||
* This class allows relative URIs, and let user retrieve URI instance if strict validation needed
|
||||
*/
|
||||
abstract class AbstractDate implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* Date formats according to RFC 2616
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3
|
||||
*/
|
||||
const DATE_RFC1123 = 0;
|
||||
const DATE_RFC1036 = 1;
|
||||
const DATE_ANSIC = 2;
|
||||
|
||||
/**
|
||||
* Date instance for this header
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $date = null;
|
||||
|
||||
/**
|
||||
* Date output format
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $dateFormat = 'D, d M Y H:i:s \G\M\T';
|
||||
|
||||
/**
|
||||
* Date formats defined by RFC 2616. RFC 1123 date is required
|
||||
* RFC 1036 and ANSI C formats are provided for compatibility with old servers/clients
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $dateFormats = [
|
||||
self::DATE_RFC1123 => 'D, d M Y H:i:s \G\M\T',
|
||||
self::DATE_RFC1036 => 'D, d M y H:i:s \G\M\T',
|
||||
self::DATE_ANSIC => 'D M j H:i:s Y',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create date-based header from string
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @return AbstractDate
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
$dateHeader = new static();
|
||||
|
||||
list($name, $date) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== strtolower($dateHeader->getFieldName())) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid header line for "' . $dateHeader->getFieldName() . '" header string'
|
||||
);
|
||||
}
|
||||
|
||||
$dateHeader->setDate($date);
|
||||
|
||||
return $dateHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create date-based header from strtotime()-compatible string
|
||||
*
|
||||
* @param int|string $time
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public static function fromTimeString($time)
|
||||
{
|
||||
return static::fromTimestamp(strtotime($time));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create date-based header from Unix timestamp
|
||||
*
|
||||
* @param int $time
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public static function fromTimestamp($time)
|
||||
{
|
||||
$dateHeader = new static();
|
||||
|
||||
if (! $time || ! is_numeric($time)) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid time for "' . $dateHeader->getFieldName() . '" header string'
|
||||
);
|
||||
}
|
||||
|
||||
$dateHeader->setDate(new DateTime('@' . $time));
|
||||
|
||||
return $dateHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set date output format
|
||||
*
|
||||
* @param int $format
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public static function setDateFormat($format)
|
||||
{
|
||||
if (!isset(static::$dateFormats[$format])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
"No constant defined for provided date format: {$format}"
|
||||
);
|
||||
}
|
||||
|
||||
static::$dateFormat = static::$dateFormats[$format];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current date output format
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDateFormat()
|
||||
{
|
||||
return static::$dateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the date for this header, this can be a string or an instance of \DateTime
|
||||
*
|
||||
* @param string|DateTime $date
|
||||
* @return AbstractDate
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function setDate($date)
|
||||
{
|
||||
if (is_string($date)) {
|
||||
try {
|
||||
$date = new DateTime($date, new DateTimeZone('GMT'));
|
||||
} catch (\Exception $e) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
sprintf('Invalid date passed as string (%s)', (string) $date),
|
||||
$e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
} elseif (!($date instanceof DateTime)) {
|
||||
throw new Exception\InvalidArgumentException('Date must be an instance of \DateTime or a string');
|
||||
}
|
||||
|
||||
$date->setTimezone(new DateTimeZone('GMT'));
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return date for this header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date()->format(static::$dateFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return date for this header as an instance of \DateTime
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function date()
|
||||
{
|
||||
if ($this->date === null) {
|
||||
$this->date = new DateTime(null, new DateTimeZone('GMT'));
|
||||
}
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare provided date to date for this header
|
||||
* Returns < 0 if date in header is less than $date; > 0 if it's greater, and 0 if they are equal.
|
||||
* @see \strcmp()
|
||||
*
|
||||
* @param string|DateTime $date
|
||||
* @return int
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function compareTo($date)
|
||||
{
|
||||
if (is_string($date)) {
|
||||
try {
|
||||
$date = new DateTime($date, new DateTimeZone('GMT'));
|
||||
} catch (\Exception $e) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
sprintf('Invalid Date passed as string (%s)', (string) $date),
|
||||
$e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
} elseif (!($date instanceof DateTime)) {
|
||||
throw new Exception\InvalidArgumentException('Date must be an instance of \DateTime or a string');
|
||||
}
|
||||
|
||||
$dateTimestamp = $date->getTimestamp();
|
||||
$thisTimestamp = $this->date()->getTimestamp();
|
||||
|
||||
return ($thisTimestamp === $dateTimestamp) ? 0 : (($thisTimestamp > $dateTimestamp) ? 1 : -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header value as formatted date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->getDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return header line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->getFieldName() . ': ' . $this->getDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow casting to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toString();
|
||||
}
|
||||
}
|
145
vendor/zendframework/zend-http/src/Header/AbstractLocation.php
vendored
Normal file
145
vendor/zendframework/zend-http/src/Header/AbstractLocation.php
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use Zend\Uri\Exception as UriException;
|
||||
use Zend\Uri\UriFactory;
|
||||
use Zend\Uri\UriInterface;
|
||||
|
||||
/**
|
||||
* Abstract Location Header
|
||||
* Supports headers that have URI as value
|
||||
* @see Zend\Http\Header\Location
|
||||
* @see Zend\Http\Header\ContentLocation
|
||||
* @see Zend\Http\Header\Referer
|
||||
*
|
||||
* Note for 'Location' header:
|
||||
* While RFC 1945 requires an absolute URI, most of the browsers also support relative URI
|
||||
* This class allows relative URIs, and let user retrieve URI instance if strict validation needed
|
||||
*/
|
||||
abstract class AbstractLocation implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* URI for this header
|
||||
*
|
||||
* @var UriInterface
|
||||
*/
|
||||
protected $uri = null;
|
||||
|
||||
/**
|
||||
* Create location-based header from string
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @return AbstractLocation
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
$locationHeader = new static();
|
||||
|
||||
// ZF-5520 - IIS bug, no space after colon
|
||||
list($name, $uri) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== strtolower($locationHeader->getFieldName())) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid header line for "' . $locationHeader->getFieldName() . '" header string'
|
||||
);
|
||||
}
|
||||
|
||||
HeaderValue::assertValid($uri);
|
||||
$locationHeader->setUri(trim($uri));
|
||||
|
||||
return $locationHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the URI/URL for this header, this can be a string or an instance of Zend\Uri\Http
|
||||
*
|
||||
* @param string|UriInterface $uri
|
||||
* @return AbstractLocation
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function setUri($uri)
|
||||
{
|
||||
if (is_string($uri)) {
|
||||
try {
|
||||
$uri = UriFactory::factory($uri);
|
||||
} catch (UriException\InvalidUriPartException $e) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
sprintf('Invalid URI passed as string (%s)', (string) $uri),
|
||||
$e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
} elseif (!($uri instanceof UriInterface)) {
|
||||
throw new Exception\InvalidArgumentException('URI must be an instance of Zend\Uri\Http or a string');
|
||||
}
|
||||
$this->uri = $uri;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the URI for this header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUri()
|
||||
{
|
||||
if ($this->uri instanceof UriInterface) {
|
||||
return $this->uri->toString();
|
||||
}
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the URI for this header as an instance of Zend\Uri\Http
|
||||
*
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function uri()
|
||||
{
|
||||
if ($this->uri === null || is_string($this->uri)) {
|
||||
$this->uri = UriFactory::factory($this->uri);
|
||||
}
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header value as URI string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->getUri();
|
||||
}
|
||||
|
||||
/**
|
||||
* Output header line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->getFieldName() . ': ' . $this->getUri();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow casting to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toString();
|
||||
}
|
||||
}
|
119
vendor/zendframework/zend-http/src/Header/Accept.php
vendored
Normal file
119
vendor/zendframework/zend-http/src/Header/Accept.php
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use Zend\Http\Header\Accept\FieldValuePart;
|
||||
|
||||
/**
|
||||
* Accept Header
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
|
||||
*/
|
||||
class Accept extends AbstractAccept
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $regexAddType = '#^([a-zA-Z+-]+|\*)/(\*|[a-zA-Z0-9+-]+)$#';
|
||||
|
||||
/**
|
||||
* Get field name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Accept';
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Accept: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a media type, with the given priority
|
||||
*
|
||||
* @param string $type
|
||||
* @param int|float $priority
|
||||
* @param array $params
|
||||
* @return Accept
|
||||
*/
|
||||
public function addMediaType($type, $priority = 1, array $params = [])
|
||||
{
|
||||
return $this->addType($type, $priority, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the header have the requested media type?
|
||||
*
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function hasMediaType($type)
|
||||
{
|
||||
return $this->hasType($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the keys contained in the header line
|
||||
*
|
||||
* @param string $fieldValuePart
|
||||
* @return FieldValuePart\AcceptFieldValuePart
|
||||
* @see \Zend\Http\Header\AbstractAccept::parseFieldValuePart()
|
||||
*/
|
||||
protected function parseFieldValuePart($fieldValuePart)
|
||||
{
|
||||
$raw = $fieldValuePart;
|
||||
if ($pos = strpos($fieldValuePart, '/')) {
|
||||
$type = trim(substr($fieldValuePart, 0, $pos));
|
||||
} else {
|
||||
$type = trim($fieldValuePart);
|
||||
}
|
||||
|
||||
$params = $this->getParametersFromFieldValuePart($fieldValuePart);
|
||||
|
||||
if ($pos = strpos($fieldValuePart, ';')) {
|
||||
$fieldValuePart = trim(substr($fieldValuePart, 0, $pos));
|
||||
}
|
||||
|
||||
if (strpos($fieldValuePart, '/')) {
|
||||
$subtypeWhole = $format = $subtype = trim(substr($fieldValuePart, strpos($fieldValuePart, '/') + 1));
|
||||
} else {
|
||||
$subtypeWhole = '';
|
||||
$format = '*';
|
||||
$subtype = '*';
|
||||
}
|
||||
|
||||
$pos = strpos($subtype, '+');
|
||||
if (false !== $pos) {
|
||||
$format = trim(substr($subtype, $pos + 1));
|
||||
$subtype = trim(substr($subtype, 0, $pos));
|
||||
}
|
||||
|
||||
$aggregated = [
|
||||
'typeString' => trim($fieldValuePart),
|
||||
'type' => $type,
|
||||
'subtype' => $subtype,
|
||||
'subtypeRaw' => $subtypeWhole,
|
||||
'format' => $format,
|
||||
'priority' => isset($params['q']) ? $params['q'] : 1,
|
||||
'params' => $params,
|
||||
'raw' => trim($raw),
|
||||
];
|
||||
|
||||
return new FieldValuePart\AcceptFieldValuePart((object) $aggregated);
|
||||
}
|
||||
}
|
113
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/AbstractFieldValuePart.php
vendored
Normal file
113
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/AbstractFieldValuePart.php
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header\Accept\FieldValuePart;
|
||||
|
||||
/**
|
||||
* Field Value Part
|
||||
*
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
|
||||
*/
|
||||
abstract class AbstractFieldValuePart
|
||||
{
|
||||
/**
|
||||
* Internal object used for value retrieval
|
||||
* @var object
|
||||
*/
|
||||
private $internalValues;
|
||||
|
||||
/**
|
||||
* A Field Value Part this Field Value Part matched against.
|
||||
* @var AbstractFieldValuePart
|
||||
*/
|
||||
protected $matchedAgainst;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param object $internalValues
|
||||
*/
|
||||
public function __construct($internalValues)
|
||||
{
|
||||
$this->internalValues = $internalValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a Field Value Part this Field Value Part matched against.
|
||||
*
|
||||
* @param AbstractFieldValuePart $matchedAgainst
|
||||
* @return AbstractFieldValuePart provides fluent interface
|
||||
*/
|
||||
public function setMatchedAgainst(AbstractFieldValuePart $matchedAgainst)
|
||||
{
|
||||
$this->matchedAgainst = $matchedAgainst;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Field Value Part this Field Value Part matched against.
|
||||
*
|
||||
* @return AbstractFieldValuePart|null
|
||||
*/
|
||||
public function getMatchedAgainst()
|
||||
{
|
||||
return $this->matchedAgainst;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
protected function getInternalValues()
|
||||
{
|
||||
return $this->internalValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string $typeString
|
||||
*/
|
||||
public function getTypeString()
|
||||
{
|
||||
return $this->getInternalValues()->typeString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float $priority
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return (float) $this->getInternalValues()->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \stdClass $params
|
||||
*/
|
||||
public function getParams()
|
||||
{
|
||||
return (object) $this->getInternalValues()->params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string $raw
|
||||
*/
|
||||
public function getRaw()
|
||||
{
|
||||
return $this->getInternalValues()->raw;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mixed
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->getInternalValues()->$key;
|
||||
}
|
||||
}
|
43
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/AcceptFieldValuePart.php
vendored
Normal file
43
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/AcceptFieldValuePart.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header\Accept\FieldValuePart;
|
||||
|
||||
/**
|
||||
* Field Value Part
|
||||
*
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
|
||||
*/
|
||||
class AcceptFieldValuePart extends AbstractFieldValuePart
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubtype()
|
||||
{
|
||||
return $this->getInternalValues()->subtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubtypeRaw()
|
||||
{
|
||||
return $this->getInternalValues()->subtypeRaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFormat()
|
||||
{
|
||||
return $this->getInternalValues()->format;
|
||||
}
|
||||
}
|
28
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/CharsetFieldValuePart.php
vendored
Normal file
28
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/CharsetFieldValuePart.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header\Accept\FieldValuePart;
|
||||
|
||||
/**
|
||||
* Field Value Part
|
||||
*
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
|
||||
*/
|
||||
class CharsetFieldValuePart extends AbstractFieldValuePart
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCharset()
|
||||
{
|
||||
return $this->getInternalValues()->type;
|
||||
}
|
||||
}
|
28
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/EncodingFieldValuePart.php
vendored
Normal file
28
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/EncodingFieldValuePart.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header\Accept\FieldValuePart;
|
||||
|
||||
/**
|
||||
* Field Value Part
|
||||
*
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
|
||||
*/
|
||||
class EncodingFieldValuePart extends AbstractFieldValuePart
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
return $this->getInternalValues()->type;
|
||||
}
|
||||
}
|
34
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/LanguageFieldValuePart.php
vendored
Normal file
34
vendor/zendframework/zend-http/src/Header/Accept/FieldValuePart/LanguageFieldValuePart.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header\Accept\FieldValuePart;
|
||||
|
||||
/**
|
||||
* Field Value Part
|
||||
*
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
|
||||
*/
|
||||
class LanguageFieldValuePart extends AbstractFieldValuePart
|
||||
{
|
||||
public function getLanguage()
|
||||
{
|
||||
return $this->getInternalValues()->typeString;
|
||||
}
|
||||
|
||||
public function getPrimaryTag()
|
||||
{
|
||||
return $this->getInternalValues()->type;
|
||||
}
|
||||
|
||||
public function getSubTag()
|
||||
{
|
||||
return $this->getInternalValues()->subtype;
|
||||
}
|
||||
}
|
79
vendor/zendframework/zend-http/src/Header/AcceptCharset.php
vendored
Normal file
79
vendor/zendframework/zend-http/src/Header/AcceptCharset.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use Zend\Http\Header\Accept\FieldValuePart;
|
||||
|
||||
/**
|
||||
* Accept Charset Header
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2
|
||||
*/
|
||||
class AcceptCharset extends AbstractAccept
|
||||
{
|
||||
protected $regexAddType = '#^([a-zA-Z0-9+-]+|\*)$#';
|
||||
|
||||
/**
|
||||
* Get field name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Accept-Charset';
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Accept-Charset: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a charset, with the given priority
|
||||
*
|
||||
* @param string $type
|
||||
* @param int|float $priority
|
||||
* @return Accept
|
||||
*/
|
||||
public function addCharset($type, $priority = 1)
|
||||
{
|
||||
return $this->addType($type, $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the header have the requested charset?
|
||||
*
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCharset($type)
|
||||
{
|
||||
return $this->hasType($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the keys contained in the header line
|
||||
*
|
||||
* @param string $fieldValuePart
|
||||
* @return \Zend\Http\Header\Accept\FieldValuePart\CharsetFieldValuePart
|
||||
* @see \Zend\Http\Header\AbstractAccept::parseFieldValuePart()
|
||||
*/
|
||||
protected function parseFieldValuePart($fieldValuePart)
|
||||
{
|
||||
$internalValues = parent::parseFieldValuePart($fieldValuePart);
|
||||
|
||||
return new FieldValuePart\CharsetFieldValuePart($internalValues);
|
||||
}
|
||||
}
|
79
vendor/zendframework/zend-http/src/Header/AcceptEncoding.php
vendored
Normal file
79
vendor/zendframework/zend-http/src/Header/AcceptEncoding.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use Zend\Http\Header\Accept\FieldValuePart;
|
||||
|
||||
/**
|
||||
* Accept Encoding Header
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
|
||||
*/
|
||||
class AcceptEncoding extends AbstractAccept
|
||||
{
|
||||
protected $regexAddType = '#^([a-zA-Z0-9+-]+|\*)$#';
|
||||
|
||||
/**
|
||||
* Get field name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Accept-Encoding';
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Accept-Encoding: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an encoding, with the given priority
|
||||
*
|
||||
* @param string $type
|
||||
* @param int|float $priority
|
||||
* @return Accept
|
||||
*/
|
||||
public function addEncoding($type, $priority = 1)
|
||||
{
|
||||
return $this->addType($type, $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the header have the requested encoding?
|
||||
*
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEncoding($type)
|
||||
{
|
||||
return $this->hasType($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the keys contained in the header line
|
||||
*
|
||||
* @param string $fieldValuePart
|
||||
* @return \Zend\Http\Header\Accept\FieldValuePart\EncodingFieldValuePart
|
||||
* @see \Zend\Http\Header\AbstractAccept::parseFieldValuePart()
|
||||
*/
|
||||
protected function parseFieldValuePart($fieldValuePart)
|
||||
{
|
||||
$internalValues = parent::parseFieldValuePart($fieldValuePart);
|
||||
|
||||
return new FieldValuePart\EncodingFieldValuePart($internalValues);
|
||||
}
|
||||
}
|
109
vendor/zendframework/zend-http/src/Header/AcceptLanguage.php
vendored
Normal file
109
vendor/zendframework/zend-http/src/Header/AcceptLanguage.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use Zend\Http\Header\Accept\FieldValuePart;
|
||||
|
||||
/**
|
||||
* Accept Language Header
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
|
||||
*/
|
||||
class AcceptLanguage extends AbstractAccept
|
||||
{
|
||||
protected $regexAddType = '#^([a-zA-Z0-9+-]+|\*)$#';
|
||||
|
||||
/**
|
||||
* Get field name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Accept-Language';
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Accept-Language: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a language, with the given priority
|
||||
*
|
||||
* @param string $type
|
||||
* @param int|float $priority
|
||||
* @return Accept
|
||||
*/
|
||||
public function addLanguage($type, $priority = 1)
|
||||
{
|
||||
return $this->addType($type, $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the header have the requested language?
|
||||
*
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLanguage($type)
|
||||
{
|
||||
return $this->hasType($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the keys contained in the header line
|
||||
*
|
||||
* @param string $fieldValuePart
|
||||
* @return \Zend\Http\Header\Accept\FieldValuePart\LanguageFieldValuePart
|
||||
* @see \Zend\Http\Header\AbstractAccept::parseFieldValuePart()
|
||||
*/
|
||||
protected function parseFieldValuePart($fieldValuePart)
|
||||
{
|
||||
$raw = $fieldValuePart;
|
||||
if ($pos = strpos($fieldValuePart, '-')) {
|
||||
$type = trim(substr($fieldValuePart, 0, $pos));
|
||||
} else {
|
||||
$type = trim(substr($fieldValuePart, 0));
|
||||
}
|
||||
|
||||
$params = $this->getParametersFromFieldValuePart($fieldValuePart);
|
||||
|
||||
if ($pos = strpos($fieldValuePart, ';')) {
|
||||
$fieldValuePart = $type = trim(substr($fieldValuePart, 0, $pos));
|
||||
}
|
||||
|
||||
if (strpos($fieldValuePart, '-')) {
|
||||
$subtypeWhole = $format = $subtype = trim(substr($fieldValuePart, strpos($fieldValuePart, '-')+1));
|
||||
} else {
|
||||
$subtypeWhole = '';
|
||||
$format = '*';
|
||||
$subtype = '*';
|
||||
}
|
||||
|
||||
$aggregated = [
|
||||
'typeString' => trim($fieldValuePart),
|
||||
'type' => $type,
|
||||
'subtype' => $subtype,
|
||||
'subtypeRaw' => $subtypeWhole,
|
||||
'format' => $format,
|
||||
'priority' => isset($params['q']) ? $params['q'] : 1,
|
||||
'params' => $params,
|
||||
'raw' => trim($raw)
|
||||
];
|
||||
|
||||
return new FieldValuePart\LanguageFieldValuePart((object) $aggregated);
|
||||
}
|
||||
}
|
70
vendor/zendframework/zend-http/src/Header/AcceptRanges.php
vendored
Normal file
70
vendor/zendframework/zend-http/src/Header/AcceptRanges.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Accept Ranges Header
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.5
|
||||
*/
|
||||
class AcceptRanges implements HeaderInterface
|
||||
{
|
||||
protected $rangeUnit;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'accept-ranges') {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid header line for Accept-Ranges string'
|
||||
);
|
||||
}
|
||||
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($rangeUnit = null)
|
||||
{
|
||||
if ($rangeUnit) {
|
||||
$this->setRangeUnit($rangeUnit);
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Accept-Ranges';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->getRangeUnit();
|
||||
}
|
||||
|
||||
public function setRangeUnit($rangeUnit)
|
||||
{
|
||||
HeaderValue::assertValid($rangeUnit);
|
||||
$this->rangeUnit = $rangeUnit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRangeUnit()
|
||||
{
|
||||
return $this->rangeUnit;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Accept-Ranges: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
109
vendor/zendframework/zend-http/src/Header/Age.php
vendored
Normal file
109
vendor/zendframework/zend-http/src/Header/Age.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Age HTTP Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.6
|
||||
*/
|
||||
class Age implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* Estimate of the amount of time in seconds since the response
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $deltaSeconds;
|
||||
|
||||
/**
|
||||
* Create Age header from string
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @return Age
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'age') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Age string: "' . $name . '"');
|
||||
}
|
||||
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($deltaSeconds = null)
|
||||
{
|
||||
if ($deltaSeconds) {
|
||||
$this->setDeltaSeconds($deltaSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Age';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header value (number of seconds)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->getDeltaSeconds();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set number of seconds
|
||||
*
|
||||
* @param int $delta
|
||||
* @return RetryAfter
|
||||
*/
|
||||
public function setDeltaSeconds($delta)
|
||||
{
|
||||
if (! is_int($delta) && ! is_numeric($delta)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid delta provided');
|
||||
}
|
||||
$this->deltaSeconds = (int) $delta;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of seconds
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDeltaSeconds()
|
||||
{
|
||||
return $this->deltaSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return header line
|
||||
* In case of overflow RFC states to set value of 2147483648 (2^31)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Age: ' . (($this->deltaSeconds >= PHP_INT_MAX) ? '2147483648' : $this->deltaSeconds);
|
||||
}
|
||||
}
|
185
vendor/zendframework/zend-http/src/Header/Allow.php
vendored
Normal file
185
vendor/zendframework/zend-http/src/Header/Allow.php
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use Zend\Http\Request;
|
||||
|
||||
/**
|
||||
* Allow Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7
|
||||
*/
|
||||
class Allow implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* List of request methods
|
||||
* true states that method is allowed, false - disallowed
|
||||
* By default GET and POST are allowed
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $methods = [
|
||||
Request::METHOD_OPTIONS => false,
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => false,
|
||||
Request::METHOD_POST => true,
|
||||
Request::METHOD_PUT => false,
|
||||
Request::METHOD_DELETE => false,
|
||||
Request::METHOD_TRACE => false,
|
||||
Request::METHOD_CONNECT => false,
|
||||
Request::METHOD_PATCH => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* Create Allow header from header line
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @return Allow
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'allow') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Allow string: "' . $name . '"');
|
||||
}
|
||||
|
||||
$header = new static();
|
||||
$header->disallowMethods(array_keys($header->getAllMethods()));
|
||||
$header->allowMethods(explode(',', $value));
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Allow';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comma-separated list of allowed methods
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
return implode(', ', array_keys($this->methods, true, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of all defined methods
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllMethods()
|
||||
{
|
||||
return $this->methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of allowed methods
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllowedMethods()
|
||||
{
|
||||
return array_keys($this->methods, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow methods or list of methods
|
||||
*
|
||||
* @param array|string $allowedMethods
|
||||
* @return Allow
|
||||
*/
|
||||
public function allowMethods($allowedMethods)
|
||||
{
|
||||
foreach ((array) $allowedMethods as $method) {
|
||||
$method = trim(strtoupper($method));
|
||||
if (preg_match('/\s/', $method)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Unable to whitelist method; "%s" is not a valid method',
|
||||
$method
|
||||
));
|
||||
}
|
||||
$this->methods[$method] = true;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disallow methods or list of methods
|
||||
*
|
||||
* @param array|string $disallowedMethods
|
||||
* @return Allow
|
||||
*/
|
||||
public function disallowMethods($disallowedMethods)
|
||||
{
|
||||
foreach ((array) $disallowedMethods as $method) {
|
||||
$method = trim(strtoupper($method));
|
||||
if (preg_match('/\s/', $method)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Unable to blacklist method; "%s" is not a valid method',
|
||||
$method
|
||||
));
|
||||
}
|
||||
$this->methods[$method] = false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience alias for @see disallowMethods()
|
||||
*
|
||||
* @param array|string $disallowedMethods
|
||||
* @return Allow
|
||||
*/
|
||||
public function denyMethods($disallowedMethods)
|
||||
{
|
||||
return $this->disallowMethods($disallowedMethods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether method is allowed
|
||||
*
|
||||
* @param string $method
|
||||
* @return bool
|
||||
*/
|
||||
public function isAllowedMethod($method)
|
||||
{
|
||||
$method = trim(strtoupper($method));
|
||||
|
||||
// disallow unknown method
|
||||
if (! isset($this->methods[$method])) {
|
||||
$this->methods[$method] = false;
|
||||
}
|
||||
|
||||
return $this->methods[$method];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return header as string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Allow: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/AuthenticationInfo.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/AuthenticationInfo.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.ietf.org/rfc/rfc2617.txt
|
||||
*/
|
||||
class AuthenticationInfo implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'authentication-info') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Authentication-Info string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Authentication-Info';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Authentication-Info: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/Authorization.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/Authorization.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.8
|
||||
*/
|
||||
class Authorization implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'authorization') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Authorization string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Authorization';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Authorization: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
252
vendor/zendframework/zend-http/src/Header/CacheControl.php
vendored
Normal file
252
vendor/zendframework/zend-http/src/Header/CacheControl.php
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
|
||||
*/
|
||||
class CacheControl implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* Array of Cache-Control directives
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $directives = [];
|
||||
|
||||
/**
|
||||
* Creates a CacheControl object from a headerLine
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return CacheControl
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'cache-control') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Cache-Control string: ""',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
HeaderValue::assertValid($value);
|
||||
$directives = static::parseValue($value);
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static();
|
||||
foreach ($directives as $key => $value) {
|
||||
$header->addDirective($key, $value);
|
||||
}
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required from HeaderDescription interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Cache-Control';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the internal directives array is empty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return empty($this->directives);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a directive
|
||||
* For directives like 'max-age=60', $value = '60'
|
||||
* For directives like 'private', use the default $value = true
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|bool $value
|
||||
* @return CacheControl - provides the fluent interface
|
||||
*/
|
||||
public function addDirective($key, $value = true)
|
||||
{
|
||||
HeaderValue::assertValid($key);
|
||||
if (! is_bool($value)) {
|
||||
HeaderValue::assertValid($value);
|
||||
}
|
||||
$this->directives[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the internal directives array for a directive
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDirective($key)
|
||||
{
|
||||
return array_key_exists($key, $this->directives);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the value of a directive from the internal directive array
|
||||
*
|
||||
* @param string $key
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDirective($key)
|
||||
{
|
||||
return array_key_exists($key, $this->directives) ? $this->directives[$key] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a directive
|
||||
*
|
||||
* @param string $key
|
||||
* @return CacheControl - provides the fluent interface
|
||||
*/
|
||||
public function removeDirective($key)
|
||||
{
|
||||
unset($this->directives[$key]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assembles the directives into a comma-delimited string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
$parts = [];
|
||||
ksort($this->directives);
|
||||
foreach ($this->directives as $key => $value) {
|
||||
if (true === $value) {
|
||||
$parts[] = $key;
|
||||
} else {
|
||||
if (preg_match('#[^a-zA-Z0-9._-]#', $value)) {
|
||||
$value = '"' . $value.'"';
|
||||
}
|
||||
$parts[] = "$key=$value";
|
||||
}
|
||||
}
|
||||
return implode(', ', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the HTTP Cache-Control header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Cache-Control: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function for parsing the value part of a
|
||||
* HTTP Cache-Control header
|
||||
*
|
||||
* @param string $value
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return array
|
||||
*/
|
||||
protected static function parseValue($value)
|
||||
{
|
||||
$value = trim($value);
|
||||
|
||||
$directives = [];
|
||||
|
||||
// handle empty string early so we don't need a separate start state
|
||||
if ($value == '') {
|
||||
return $directives;
|
||||
}
|
||||
|
||||
$lastMatch = null;
|
||||
|
||||
state_directive:
|
||||
switch (static::match(['[a-zA-Z][a-zA-Z_-]*'], $value, $lastMatch)) {
|
||||
case 0:
|
||||
$directive = $lastMatch;
|
||||
goto state_value;
|
||||
// intentional fall-through
|
||||
|
||||
default:
|
||||
throw new Exception\InvalidArgumentException('expected DIRECTIVE');
|
||||
}
|
||||
|
||||
state_value:
|
||||
switch (static::match(['="[^"]*"', '=[^",\s;]*'], $value, $lastMatch)) {
|
||||
case 0:
|
||||
$directives[$directive] = substr($lastMatch, 2, -1);
|
||||
goto state_separator;
|
||||
// intentional fall-through
|
||||
|
||||
case 1:
|
||||
$directives[$directive] = rtrim(substr($lastMatch, 1));
|
||||
goto state_separator;
|
||||
// intentional fall-through
|
||||
|
||||
default:
|
||||
$directives[$directive] = true;
|
||||
goto state_separator;
|
||||
}
|
||||
|
||||
state_separator:
|
||||
switch (static::match(['\s*,\s*', '$'], $value, $lastMatch)) {
|
||||
case 0:
|
||||
goto state_directive;
|
||||
// intentional fall-through
|
||||
|
||||
case 1:
|
||||
return $directives;
|
||||
|
||||
default:
|
||||
throw new Exception\InvalidArgumentException('expected SEPARATOR or END');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function used by parseValue to match tokens
|
||||
*
|
||||
* @param array $tokens
|
||||
* @param string $string
|
||||
* @param string $lastMatch
|
||||
* @return int
|
||||
*/
|
||||
protected static function match($tokens, &$string, &$lastMatch)
|
||||
{
|
||||
// Ensure we have a string
|
||||
$value = (string) $string;
|
||||
|
||||
foreach ($tokens as $i => $token) {
|
||||
if (preg_match('/^' . $token . '/', $value, $matches)) {
|
||||
$lastMatch = $matches[0];
|
||||
$string = substr($value, strlen($matches[0]));
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
117
vendor/zendframework/zend-http/src/Header/Connection.php
vendored
Normal file
117
vendor/zendframework/zend-http/src/Header/Connection.php
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Connection Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.10
|
||||
*/
|
||||
class Connection implements HeaderInterface
|
||||
{
|
||||
const CONNECTION_CLOSE = 'close';
|
||||
const CONNECTION_KEEP_ALIVE = 'keep-alive';
|
||||
|
||||
/**
|
||||
* Value of this header
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $value = self::CONNECTION_KEEP_ALIVE;
|
||||
|
||||
/**
|
||||
* @param $headerLine
|
||||
* @return Connection
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
$header = new static();
|
||||
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'connection') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Connection string: "' . $name . '"');
|
||||
}
|
||||
|
||||
$header->setValue(trim($value));
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Connection header to define persistent connection
|
||||
*
|
||||
* @param bool $flag
|
||||
* @return Connection
|
||||
*/
|
||||
public function setPersistent($flag)
|
||||
{
|
||||
$this->value = (bool) $flag
|
||||
? self::CONNECTION_KEEP_ALIVE
|
||||
: self::CONNECTION_CLOSE;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether this connection is persistent
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPersistent()
|
||||
{
|
||||
return ($this->value === self::CONNECTION_KEEP_ALIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set arbitrary header value
|
||||
* RFC allows any token as value, 'close' and 'keep-alive' are commonly used
|
||||
*
|
||||
* @param string $value
|
||||
* @return Connection
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = strtolower($value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Connection';
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection header value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return header line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Connection: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/ContentDisposition.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/ContentDisposition.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
|
||||
*/
|
||||
class ContentDisposition implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'content-disposition') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Content-Disposition string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-Disposition';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Content-Disposition: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
62
vendor/zendframework/zend-http/src/Header/ContentEncoding.php
vendored
Normal file
62
vendor/zendframework/zend-http/src/Header/ContentEncoding.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
|
||||
*/
|
||||
class ContentEncoding implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'content-encoding') {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid header line for Content-Encoding string: "' . $name . '"'
|
||||
);
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-Encoding';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Content-Encoding: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/ContentLanguage.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/ContentLanguage.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12
|
||||
*/
|
||||
class ContentLanguage implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'content-language') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Content-Language string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-Language';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Content-Language: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/ContentLength.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/ContentLength.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13
|
||||
*/
|
||||
class ContentLength implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'content-length') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Content-Length string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-Length';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Content-Length: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
28
vendor/zendframework/zend-http/src/Header/ContentLocation.php
vendored
Normal file
28
vendor/zendframework/zend-http/src/Header/ContentLocation.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Content-Location Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.14
|
||||
*/
|
||||
class ContentLocation extends AbstractLocation
|
||||
{
|
||||
/**
|
||||
* Return header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-Location';
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/ContentMD5.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/ContentMD5.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.15
|
||||
*/
|
||||
class ContentMD5 implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'content-md5') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Content-MD5 string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-MD5';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Content-MD5: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/ContentRange.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/ContentRange.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16
|
||||
*/
|
||||
class ContentRange implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'content-range') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Content-Range string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-Range';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Content-Range: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
153
vendor/zendframework/zend-http/src/Header/ContentSecurityPolicy.php
vendored
Normal file
153
vendor/zendframework/zend-http/src/Header/ContentSecurityPolicy.php
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Content Security Policy 1.0 Header
|
||||
*
|
||||
* @link http://www.w3.org/TR/CSP/
|
||||
*/
|
||||
class ContentSecurityPolicy implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* Valid directive names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $validDirectiveNames = [
|
||||
// As per http://www.w3.org/TR/CSP/#directives
|
||||
'default-src',
|
||||
'script-src',
|
||||
'object-src',
|
||||
'style-src',
|
||||
'img-src',
|
||||
'media-src',
|
||||
'frame-src',
|
||||
'font-src',
|
||||
'connect-src',
|
||||
'sandbox',
|
||||
'report-uri',
|
||||
];
|
||||
|
||||
/**
|
||||
* The directives defined for this policy
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $directives = [];
|
||||
|
||||
/**
|
||||
* Get the list of defined directives
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDirectives()
|
||||
{
|
||||
return $this->directives;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the directive to consist of the source list
|
||||
*
|
||||
* Reverses http://www.w3.org/TR/CSP/#parsing-1
|
||||
*
|
||||
* @param string $name The directive name.
|
||||
* @param array $sources The source list.
|
||||
* @return self
|
||||
* @throws Exception\InvalidArgumentException If the name is not a valid directive name.
|
||||
*/
|
||||
public function setDirective($name, array $sources)
|
||||
{
|
||||
if (! in_array($name, $this->validDirectiveNames, true)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects a valid directive name; received "%s"',
|
||||
__METHOD__,
|
||||
(string) $name
|
||||
));
|
||||
}
|
||||
if (empty($sources)) {
|
||||
$this->directives[$name] = "'none'";
|
||||
return $this;
|
||||
}
|
||||
|
||||
array_walk($sources, [__NAMESPACE__ . '\HeaderValue', 'assertValid']);
|
||||
|
||||
$this->directives[$name] = implode(' ', $sources);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Content Security Policy header from a given header line
|
||||
*
|
||||
* @param string $headerLine The header line to parse.
|
||||
* @return self
|
||||
* @throws Exception\InvalidArgumentException If the name field in the given header line does not match.
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
$header = new static();
|
||||
$headerName = $header->getFieldName();
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
// Ensure the proper header name
|
||||
if (strcasecmp($name, $headerName) != 0) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for %s string: "%s"',
|
||||
$headerName,
|
||||
$name
|
||||
));
|
||||
}
|
||||
// As per http://www.w3.org/TR/CSP/#parsing
|
||||
$tokens = explode(';', $value);
|
||||
foreach ($tokens as $token) {
|
||||
$token = trim($token);
|
||||
if ($token) {
|
||||
list($directiveName, $directiveValue) = explode(' ', $token, 2);
|
||||
if (!isset($header->directives[$directiveName])) {
|
||||
$header->setDirective($directiveName, [$directiveValue]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-Security-Policy';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the header value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
$directives = [];
|
||||
foreach ($this->directives as $name => $value) {
|
||||
$directives[] = sprintf('%s %s;', $name, $value);
|
||||
}
|
||||
return implode(' ', $directives);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the header as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return sprintf('%s: %s', $this->getFieldName(), $this->getFieldValue());
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/ContentTransferEncoding.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/ContentTransferEncoding.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 @todo find section
|
||||
*/
|
||||
class ContentTransferEncoding implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'content-transfer-encoding') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Content-Transfer-Encoding string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static(strtolower($value));
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-Transfer-Encoding';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Content-Transfer-Encoding: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
404
vendor/zendframework/zend-http/src/Header/ContentType.php
vendored
Normal file
404
vendor/zendframework/zend-http/src/Header/ContentType.php
vendored
Normal file
@@ -0,0 +1,404 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
|
||||
*/
|
||||
class ContentType implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $mediaType;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $parameters = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* Factory method: create an object from a string representation
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @return self
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'content-type') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Content-Type string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
$parts = explode(';', $value);
|
||||
$mediaType = array_shift($parts);
|
||||
$header = new static($value, trim($mediaType));
|
||||
|
||||
if (count($parts) > 0) {
|
||||
$parameters = [];
|
||||
foreach ($parts as $parameter) {
|
||||
$parameter = trim($parameter);
|
||||
if (!preg_match('/^(?P<key>[^\s\=]+)\="?(?P<value>[^\s\"]*)"?$/', $parameter, $matches)) {
|
||||
continue;
|
||||
}
|
||||
$parameters[$matches['key']] = $matches['value'];
|
||||
}
|
||||
$header->setParameters($parameters);
|
||||
}
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null, $mediaType = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
$this->mediaType = $mediaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the mediatype value in this header matches the provided criteria
|
||||
*
|
||||
* @param array|string $matchAgainst
|
||||
* @return string|bool Matched value or false
|
||||
*/
|
||||
public function match($matchAgainst)
|
||||
{
|
||||
if (is_string($matchAgainst)) {
|
||||
$matchAgainst = $this->splitMediaTypesFromString($matchAgainst);
|
||||
}
|
||||
|
||||
$mediaType = $this->getMediaType();
|
||||
$left = $this->getMediaTypeObjectFromString($mediaType);
|
||||
|
||||
foreach ($matchAgainst as $matchType) {
|
||||
$matchType = strtolower($matchType);
|
||||
|
||||
if ($mediaType == $matchType) {
|
||||
return $matchType;
|
||||
}
|
||||
|
||||
$right = $this->getMediaTypeObjectFromString($matchType);
|
||||
|
||||
// Is the right side a wildcard type?
|
||||
if ($right->type == '*') {
|
||||
if ($this->validateSubtype($right, $left)) {
|
||||
return $matchType;
|
||||
}
|
||||
}
|
||||
|
||||
// Do the types match?
|
||||
if ($right->type == $left->type) {
|
||||
if ($this->validateSubtype($right, $left)) {
|
||||
return $matchType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a string representation of the header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Content-Type: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Content-Type';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
if (null !== $this->value) {
|
||||
return $this->value;
|
||||
}
|
||||
return $this->assembleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the media type
|
||||
*
|
||||
* @param string $mediaType
|
||||
* @return self
|
||||
*/
|
||||
public function setMediaType($mediaType)
|
||||
{
|
||||
HeaderValue::assertValid($mediaType);
|
||||
$this->mediaType = strtolower($mediaType);
|
||||
$this->value = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the media type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaType()
|
||||
{
|
||||
return $this->mediaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set additional content-type parameters
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return self
|
||||
*/
|
||||
public function setParameters(array $parameters)
|
||||
{
|
||||
foreach ($parameters as $key => $value) {
|
||||
HeaderValue::assertValid($key);
|
||||
HeaderValue::assertValid($value);
|
||||
}
|
||||
$this->parameters = array_merge($this->parameters, $parameters);
|
||||
$this->value = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any additional content-type parameters currently set
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content-type character set encoding
|
||||
*
|
||||
* @param string $charset
|
||||
* @return self
|
||||
*/
|
||||
public function setCharset($charset)
|
||||
{
|
||||
HeaderValue::assertValid($charset);
|
||||
$this->parameters['charset'] = $charset;
|
||||
$this->value = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content-type character set encoding, if any
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getCharset()
|
||||
{
|
||||
if (isset($this->parameters['charset'])) {
|
||||
return $this->parameters['charset'];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assemble the value based on the media type and any available parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function assembleValue()
|
||||
{
|
||||
$mediaType = $this->getMediaType();
|
||||
if (empty($this->parameters)) {
|
||||
return $mediaType;
|
||||
}
|
||||
|
||||
$parameters = [];
|
||||
foreach ($this->parameters as $key => $value) {
|
||||
$parameters[] = sprintf('%s=%s', $key, $value);
|
||||
}
|
||||
|
||||
return sprintf('%s; %s', $mediaType, implode('; ', $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Split comma-separated media types into an array
|
||||
*
|
||||
* @param string $criteria
|
||||
* @return array
|
||||
*/
|
||||
protected function splitMediaTypesFromString($criteria)
|
||||
{
|
||||
$mediaTypes = explode(',', $criteria);
|
||||
array_walk(
|
||||
$mediaTypes,
|
||||
function (&$value) {
|
||||
$value = trim($value);
|
||||
}
|
||||
);
|
||||
|
||||
return $mediaTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a mediatype string into an object with the following parts:
|
||||
*
|
||||
* - type
|
||||
* - subtype
|
||||
* - format
|
||||
*
|
||||
* @param string $string
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function getMediaTypeObjectFromString($string)
|
||||
{
|
||||
if (!is_string($string)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Non-string mediatype "%s" provided',
|
||||
(is_object($string) ? get_class($string) : gettype($string))
|
||||
));
|
||||
}
|
||||
|
||||
$parts = explode('/', $string, 2);
|
||||
if (1 == count($parts)) {
|
||||
throw new Exception\DomainException(sprintf(
|
||||
'Invalid mediatype "%s" provided',
|
||||
$string
|
||||
));
|
||||
}
|
||||
|
||||
$type = array_shift($parts);
|
||||
$subtype = array_shift($parts);
|
||||
$format = $subtype;
|
||||
if (strstr($subtype, '+')) {
|
||||
$parts = explode('+', $subtype, 2);
|
||||
$subtype = array_shift($parts);
|
||||
$format = array_shift($parts);
|
||||
}
|
||||
|
||||
$mediaType = (object) [
|
||||
'type' => $type,
|
||||
'subtype' => $subtype,
|
||||
'format' => $format,
|
||||
];
|
||||
|
||||
return $mediaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a subtype
|
||||
*
|
||||
* @param stdClass $right
|
||||
* @param stdClass $left
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateSubtype($right, $left)
|
||||
{
|
||||
// Is the right side a wildcard subtype?
|
||||
if ($right->subtype == '*') {
|
||||
return $this->validateFormat($right, $left);
|
||||
}
|
||||
|
||||
// Do the right side and left side subtypes match?
|
||||
if ($right->subtype == $left->subtype) {
|
||||
return $this->validateFormat($right, $left);
|
||||
}
|
||||
|
||||
// Is the right side a partial wildcard?
|
||||
if ('*' == substr($right->subtype, -1)) {
|
||||
// validate partial-wildcard subtype
|
||||
if (!$this->validatePartialWildcard($right->subtype, $left->subtype)) {
|
||||
return false;
|
||||
}
|
||||
// Finally, verify format is valid
|
||||
return $this->validateFormat($right, $left);
|
||||
}
|
||||
|
||||
// Does the right side subtype match the left side format?
|
||||
if ($right->subtype == $left->format) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// At this point, there is no valid match
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the format
|
||||
*
|
||||
* Validate that the right side format matches what the left side defines.
|
||||
*
|
||||
* @param string $right
|
||||
* @param string $left
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateFormat($right, $left)
|
||||
{
|
||||
if ($right->format && $left->format) {
|
||||
if ($right->format == '*') {
|
||||
return true;
|
||||
}
|
||||
if ($right->format == $left->format) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a partial wildcard (i.e., string ending in '*')
|
||||
*
|
||||
* @param string $right
|
||||
* @param string $left
|
||||
* @return bool
|
||||
*/
|
||||
protected function validatePartialWildcard($right, $left)
|
||||
{
|
||||
$requiredSegment = substr($right, 0, strlen($right) - 1);
|
||||
if ($requiredSegment == $left) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strlen($requiredSegment) >= strlen($left)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 === strpos($left, $requiredSegment)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
122
vendor/zendframework/zend-http/src/Header/Cookie.php
vendored
Normal file
122
vendor/zendframework/zend-http/src/Header/Cookie.php
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use ArrayObject;
|
||||
|
||||
/**
|
||||
* @see http://www.ietf.org/rfc/rfc2109.txt
|
||||
* @see http://www.w3.org/Protocols/rfc2109/rfc2109
|
||||
*/
|
||||
class Cookie extends ArrayObject implements HeaderInterface
|
||||
{
|
||||
protected $encodeValue = true;
|
||||
|
||||
public static function fromSetCookieArray(array $setCookies)
|
||||
{
|
||||
$nvPairs = [];
|
||||
|
||||
foreach ($setCookies as $setCookie) {
|
||||
if (! $setCookie instanceof SetCookie) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s requires an array of SetCookie objects',
|
||||
__METHOD__
|
||||
));
|
||||
}
|
||||
|
||||
if (array_key_exists($setCookie->getName(), $nvPairs)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Two cookies with the same name were provided to %s',
|
||||
__METHOD__
|
||||
));
|
||||
}
|
||||
|
||||
$nvPairs[$setCookie->getName()] = $setCookie->getValue();
|
||||
}
|
||||
|
||||
return new static($nvPairs);
|
||||
}
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
$header = new static();
|
||||
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'cookie') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Server string: "' . $name . '"');
|
||||
}
|
||||
|
||||
$nvPairs = preg_split('#;\s*#', $value);
|
||||
|
||||
$arrayInfo = [];
|
||||
foreach ($nvPairs as $nvPair) {
|
||||
$parts = explode('=', $nvPair, 2);
|
||||
if (count($parts) != 2) {
|
||||
throw new Exception\RuntimeException('Malformed Cookie header found');
|
||||
}
|
||||
list($name, $value) = $parts;
|
||||
$arrayInfo[$name] = urldecode($value);
|
||||
}
|
||||
|
||||
$header->exchangeArray($arrayInfo);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct(array $array = [])
|
||||
{
|
||||
parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);
|
||||
}
|
||||
|
||||
public function setEncodeValue($encodeValue)
|
||||
{
|
||||
$this->encodeValue = (bool) $encodeValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEncodeValue()
|
||||
{
|
||||
return $this->encodeValue;
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Cookie';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
$nvPairs = [];
|
||||
|
||||
foreach ($this as $name => $value) {
|
||||
$nvPairs[] = $name . '=' . (($this->encodeValue) ? urlencode($value) : $value);
|
||||
}
|
||||
|
||||
return implode('; ', $nvPairs);
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Cookie: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cookie as a string, suitable for sending as a "Cookie" header in an
|
||||
* HTTP request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toString();
|
||||
}
|
||||
}
|
28
vendor/zendframework/zend-http/src/Header/Date.php
vendored
Normal file
28
vendor/zendframework/zend-http/src/Header/Date.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Date Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18
|
||||
*/
|
||||
class Date extends AbstractDate
|
||||
{
|
||||
/**
|
||||
* Get header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Date';
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Etag.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Etag.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19
|
||||
*/
|
||||
class Etag implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'etag') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Etag string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Etag';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Etag: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
14
vendor/zendframework/zend-http/src/Header/Exception/DomainException.php
vendored
Normal file
14
vendor/zendframework/zend-http/src/Header/Exception/DomainException.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header\Exception;
|
||||
|
||||
class DomainException extends \DomainException implements ExceptionInterface
|
||||
{
|
||||
}
|
16
vendor/zendframework/zend-http/src/Header/Exception/ExceptionInterface.php
vendored
Normal file
16
vendor/zendframework/zend-http/src/Header/Exception/ExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header\Exception;
|
||||
|
||||
use Zend\Http\Exception\ExceptionInterface as HttpException;
|
||||
|
||||
interface ExceptionInterface extends HttpException
|
||||
{
|
||||
}
|
17
vendor/zendframework/zend-http/src/Header/Exception/InvalidArgumentException.php
vendored
Normal file
17
vendor/zendframework/zend-http/src/Header/Exception/InvalidArgumentException.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header\Exception;
|
||||
|
||||
use Zend\Http\Exception;
|
||||
|
||||
class InvalidArgumentException extends Exception\InvalidArgumentException implements
|
||||
ExceptionInterface
|
||||
{
|
||||
}
|
17
vendor/zendframework/zend-http/src/Header/Exception/RuntimeException.php
vendored
Normal file
17
vendor/zendframework/zend-http/src/Header/Exception/RuntimeException.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header\Exception;
|
||||
|
||||
use Zend\Http\Exception;
|
||||
|
||||
class RuntimeException extends Exception\RuntimeException implements
|
||||
ExceptionInterface
|
||||
{
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Expect.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Expect.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.20
|
||||
*/
|
||||
class Expect implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'expect') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Expect string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Expect';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Expect: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
28
vendor/zendframework/zend-http/src/Header/Expires.php
vendored
Normal file
28
vendor/zendframework/zend-http/src/Header/Expires.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Expires Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21
|
||||
*/
|
||||
class Expires extends AbstractDate
|
||||
{
|
||||
/**
|
||||
* Get header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Expires';
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/From.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/From.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.22
|
||||
*/
|
||||
class From implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'from') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for From string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'From';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'From: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
164
vendor/zendframework/zend-http/src/Header/GenericHeader.php
vendored
Normal file
164
vendor/zendframework/zend-http/src/Header/GenericHeader.php
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Content-Location Header
|
||||
*
|
||||
*/
|
||||
class GenericHeader implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fieldName = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fieldValue = null;
|
||||
|
||||
/**
|
||||
* Factory to generate a header object from a string
|
||||
*
|
||||
* @static
|
||||
* @param string $headerLine
|
||||
* @return GenericHeader
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
|
||||
$header = new static($fieldName, $fieldValue);
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the header line in `name` and `value` parts.
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @return string[] `name` in the first index and `value` in the second.
|
||||
* @throws Exception\InvalidArgumentException If header does not match with the format ``name:value``
|
||||
*/
|
||||
public static function splitHeaderLine($headerLine)
|
||||
{
|
||||
$parts = explode(':', $headerLine, 2);
|
||||
if (count($parts) !== 2) {
|
||||
throw new Exception\InvalidArgumentException('Header must match with the format "name:value"');
|
||||
}
|
||||
|
||||
if (! HeaderValue::isValid($parts[1])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid header value detected');
|
||||
}
|
||||
|
||||
$parts[1] = ltrim($parts[1]);
|
||||
|
||||
return $parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param null|string $fieldName
|
||||
* @param null|string $fieldValue
|
||||
*/
|
||||
public function __construct($fieldName = null, $fieldValue = null)
|
||||
{
|
||||
if ($fieldName) {
|
||||
$this->setFieldName($fieldName);
|
||||
}
|
||||
|
||||
if ($fieldValue !== null) {
|
||||
$this->setFieldValue($fieldValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set header field name
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return GenericHeader
|
||||
* @throws Exception\InvalidArgumentException If the name does not match with RFC 2616 format.
|
||||
*/
|
||||
public function setFieldName($fieldName)
|
||||
{
|
||||
if (!is_string($fieldName) || empty($fieldName)) {
|
||||
throw new Exception\InvalidArgumentException('Header name must be a string');
|
||||
}
|
||||
|
||||
/*
|
||||
* Following RFC 7230 section 3.2
|
||||
*
|
||||
* header-field = field-name ":" [ field-value ]
|
||||
* field-name = token
|
||||
* token = 1*tchar
|
||||
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /
|
||||
* "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
|
||||
*/
|
||||
if (!preg_match('/^[!#$%&\'*+\-\.\^_`|~0-9a-zA-Z]+$/', $fieldName)) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Header name must be a valid RFC 7230 (section 3.2) field-name.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->fieldName = $fieldName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve header field name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return $this->fieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set header field value
|
||||
*
|
||||
* @param string $fieldValue
|
||||
* @return GenericHeader
|
||||
*/
|
||||
public function setFieldValue($fieldValue)
|
||||
{
|
||||
$fieldValue = (string) $fieldValue;
|
||||
HeaderValue::assertValid($fieldValue);
|
||||
|
||||
if (preg_match('/^\s+$/', $fieldValue)) {
|
||||
$fieldValue = '';
|
||||
}
|
||||
|
||||
$this->fieldValue = $fieldValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve header field value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->fieldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast to string as a well formed HTTP header line
|
||||
*
|
||||
* Returns in form of "NAME: VALUE\r\n"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->getFieldName() . ': ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
42
vendor/zendframework/zend-http/src/Header/GenericMultiHeader.php
vendored
Normal file
42
vendor/zendframework/zend-http/src/Header/GenericMultiHeader.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
class GenericMultiHeader extends GenericHeader implements MultipleHeaderInterface
|
||||
{
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
if (strpos($fieldValue, ',')) {
|
||||
$headers = [];
|
||||
foreach (explode(',', $fieldValue) as $multiValue) {
|
||||
$headers[] = new static($fieldName, $multiValue);
|
||||
}
|
||||
return $headers;
|
||||
} else {
|
||||
$header = new static($fieldName, $fieldValue);
|
||||
return $header;
|
||||
}
|
||||
}
|
||||
|
||||
public function toStringMultipleHeaders(array $headers)
|
||||
{
|
||||
$name = $this->getFieldName();
|
||||
$values = [$this->getFieldValue()];
|
||||
foreach ($headers as $header) {
|
||||
if (!$header instanceof static) {
|
||||
throw new Exception\InvalidArgumentException('This method toStringMultipleHeaders was expecting an array of headers of the same type');
|
||||
}
|
||||
$values[] = $header->getFieldValue();
|
||||
}
|
||||
return $name . ': ' . implode(',', $values) . "\r\n";
|
||||
}
|
||||
}
|
49
vendor/zendframework/zend-http/src/Header/HeaderInterface.php
vendored
Normal file
49
vendor/zendframework/zend-http/src/Header/HeaderInterface.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Interface for HTTP Header classes.
|
||||
*/
|
||||
interface HeaderInterface
|
||||
{
|
||||
/**
|
||||
* Factory to generate a header object from a string
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @return self
|
||||
* @throws Exception\InvalidArgumentException If the header does not match RFC 2616 definition.
|
||||
* @see http://tools.ietf.org/html/rfc2616#section-4.2
|
||||
*/
|
||||
public static function fromString($headerLine);
|
||||
|
||||
/**
|
||||
* Retrieve header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName();
|
||||
|
||||
/**
|
||||
* Retrieve header value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue();
|
||||
|
||||
/**
|
||||
* Cast to string
|
||||
*
|
||||
* Returns in form of "NAME: VALUE"
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString();
|
||||
}
|
107
vendor/zendframework/zend-http/src/Header/HeaderValue.php
vendored
Normal file
107
vendor/zendframework/zend-http/src/Header/HeaderValue.php
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
final class HeaderValue
|
||||
{
|
||||
/**
|
||||
* Private constructor; non-instantiable.
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter a header value
|
||||
*
|
||||
* Ensures CRLF header injection vectors are filtered.
|
||||
*
|
||||
* Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal
|
||||
* tabs are allowed in values; only one whitespace character is allowed
|
||||
* between visible characters.
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/HTTP_response_splitting
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public static function filter($value)
|
||||
{
|
||||
$value = (string) $value;
|
||||
$length = strlen($value);
|
||||
$string = '';
|
||||
for ($i = 0; $i < $length; $i += 1) {
|
||||
$ascii = ord($value[$i]);
|
||||
|
||||
// Non-visible, non-whitespace characters
|
||||
// 9 === horizontal tab
|
||||
// 32-126, 128-254 === visible
|
||||
// 127 === DEL
|
||||
// 255 === null byte
|
||||
if (($ascii < 32 && $ascii !== 9)
|
||||
|| $ascii === 127
|
||||
|| $ascii > 254
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$string .= $value[$i];
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a header value.
|
||||
*
|
||||
* Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal
|
||||
* tabs are allowed in values; only one whitespace character is allowed
|
||||
* between visible characters.
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/HTTP_response_splitting
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValid($value)
|
||||
{
|
||||
$value = (string) $value;
|
||||
$length = strlen($value);
|
||||
for ($i = 0; $i < $length; $i += 1) {
|
||||
$ascii = ord($value[$i]);
|
||||
|
||||
// Non-visible, non-whitespace characters
|
||||
// 9 === horizontal tab
|
||||
// 32-126, 128-254 === visible
|
||||
// 127 === DEL
|
||||
// 255 === null byte
|
||||
if (($ascii < 32 && $ascii !== 9)
|
||||
|| $ascii === 127
|
||||
|| $ascii > 254
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a header value is valid.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws Exception\RuntimeException for invalid values
|
||||
* @return void
|
||||
*/
|
||||
public static function assertValid($value)
|
||||
{
|
||||
if (! self::isValid($value)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid header value');
|
||||
}
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Host.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Host.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23
|
||||
*/
|
||||
class Host implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'host') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Host string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Host';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Host: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/IfMatch.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/IfMatch.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
|
||||
*/
|
||||
class IfMatch implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'if-match') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for If-Match string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'If-Match';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'If-Match: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
28
vendor/zendframework/zend-http/src/Header/IfModifiedSince.php
vendored
Normal file
28
vendor/zendframework/zend-http/src/Header/IfModifiedSince.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* If-Modified-Since Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25
|
||||
*/
|
||||
class IfModifiedSince extends AbstractDate
|
||||
{
|
||||
/**
|
||||
* Get header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'If-Modified-Since';
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/IfNoneMatch.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/IfNoneMatch.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26
|
||||
*/
|
||||
class IfNoneMatch implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'if-none-match') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for If-None-Match string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'If-None-Match';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'If-None-Match: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/IfRange.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/IfRange.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.27
|
||||
*/
|
||||
class IfRange implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'if-range') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for If-Range string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'If-Range';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'If-Range: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
28
vendor/zendframework/zend-http/src/Header/IfUnmodifiedSince.php
vendored
Normal file
28
vendor/zendframework/zend-http/src/Header/IfUnmodifiedSince.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* If-Unmodified-Since Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.28
|
||||
*/
|
||||
class IfUnmodifiedSince extends AbstractDate
|
||||
{
|
||||
/**
|
||||
* Get header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'If-Unmodified-Since';
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/KeepAlive.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/KeepAlive.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @todo Search for RFC for this header
|
||||
*/
|
||||
class KeepAlive implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'keep-alive') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Keep-Alive string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Keep-Alive';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Keep-Alive: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
28
vendor/zendframework/zend-http/src/Header/LastModified.php
vendored
Normal file
28
vendor/zendframework/zend-http/src/Header/LastModified.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Last-Modified Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29
|
||||
*/
|
||||
class LastModified extends AbstractDate
|
||||
{
|
||||
/**
|
||||
* Get header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Last-Modified';
|
||||
}
|
||||
}
|
28
vendor/zendframework/zend-http/src/Header/Location.php
vendored
Normal file
28
vendor/zendframework/zend-http/src/Header/Location.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Location Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30
|
||||
*/
|
||||
class Location extends AbstractLocation
|
||||
{
|
||||
/**
|
||||
* Return header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Location';
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/MaxForwards.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/MaxForwards.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.31
|
||||
*/
|
||||
class MaxForwards implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'max-forwards') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Max-Forwards string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Max-Forwards';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Max-Forwards: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
15
vendor/zendframework/zend-http/src/Header/MultipleHeaderInterface.php
vendored
Normal file
15
vendor/zendframework/zend-http/src/Header/MultipleHeaderInterface.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
interface MultipleHeaderInterface extends HeaderInterface
|
||||
{
|
||||
public function toStringMultipleHeaders(array $headers);
|
||||
}
|
67
vendor/zendframework/zend-http/src/Header/Origin.php
vendored
Normal file
67
vendor/zendframework/zend-http/src/Header/Origin.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use Zend\Uri\UriFactory;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://tools.ietf.org/id/draft-abarth-origin-03.html#rfc.section.2
|
||||
*/
|
||||
class Origin implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value = '';
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = explode(': ', $headerLine, 2);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'origin') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Origin string: "' . $name . '"');
|
||||
}
|
||||
|
||||
$uri = UriFactory::factory($value);
|
||||
if (!$uri->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid header value for Origin key: "' . $name . '"');
|
||||
}
|
||||
|
||||
return new static($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $value
|
||||
*/
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Origin';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Origin: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Pragma.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Pragma.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32
|
||||
*/
|
||||
class Pragma implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'pragma') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Pragma string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Pragma';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Pragma: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
78
vendor/zendframework/zend-http/src/Header/ProxyAuthenticate.php
vendored
Normal file
78
vendor/zendframework/zend-http/src/Header/ProxyAuthenticate.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.33
|
||||
*/
|
||||
class ProxyAuthenticate implements MultipleHeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'proxy-authenticate') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Proxy-Authenticate string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Proxy-Authenticate';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Proxy-Authenticate: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
public function toStringMultipleHeaders(array $headers)
|
||||
{
|
||||
$strings = [$this->toString()];
|
||||
foreach ($headers as $header) {
|
||||
if (!$header instanceof ProxyAuthenticate) {
|
||||
throw new Exception\RuntimeException(
|
||||
'The ProxyAuthenticate multiple header implementation can only accept'
|
||||
. ' an array of ProxyAuthenticate headers'
|
||||
);
|
||||
}
|
||||
$strings[] = $header->toString();
|
||||
}
|
||||
return implode("\r\n", $strings);
|
||||
}
|
||||
}
|
63
vendor/zendframework/zend-http/src/Header/ProxyAuthorization.php
vendored
Normal file
63
vendor/zendframework/zend-http/src/Header/ProxyAuthorization.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.34
|
||||
*/
|
||||
class ProxyAuthorization implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'proxy-authorization') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for Proxy-Authorization string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Proxy-Authorization';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Proxy-Authorization: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Range.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Range.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2
|
||||
*/
|
||||
class Range implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'range') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Range string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Range';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Range: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
45
vendor/zendframework/zend-http/src/Header/Referer.php
vendored
Normal file
45
vendor/zendframework/zend-http/src/Header/Referer.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use Zend\Uri\Http as HttpUri;
|
||||
|
||||
/**
|
||||
* Content-Location Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.36
|
||||
*/
|
||||
class Referer extends AbstractLocation
|
||||
{
|
||||
/**
|
||||
* Set the URI/URL for this header
|
||||
* according to RFC Referer URI should not have fragment
|
||||
*
|
||||
* @param string|HttpUri $uri
|
||||
* @return Referer
|
||||
*/
|
||||
public function setUri($uri)
|
||||
{
|
||||
parent::setUri($uri);
|
||||
$this->uri->setFragment(null);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Referer';
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Refresh.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Refresh.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @todo FIND SPEC FOR THIS
|
||||
*/
|
||||
class Refresh implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'refresh') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Refresh string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Refresh';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Refresh: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
107
vendor/zendframework/zend-http/src/Header/RetryAfter.php
vendored
Normal file
107
vendor/zendframework/zend-http/src/Header/RetryAfter.php
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* Retry-After HTTP Header
|
||||
*
|
||||
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37
|
||||
*/
|
||||
class RetryAfter extends AbstractDate
|
||||
{
|
||||
/**
|
||||
* Value of header in delta-seconds
|
||||
* By default set to 1 hour
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $deltaSeconds = 3600;
|
||||
|
||||
/**
|
||||
* Create Retry-After header from string
|
||||
*
|
||||
* @param string $headerLine
|
||||
* @return RetryAfter
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
$dateHeader = new static();
|
||||
|
||||
list($name, $date) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== strtolower($dateHeader->getFieldName())) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid header line for "' . $dateHeader->getFieldName() . '" header string'
|
||||
);
|
||||
}
|
||||
|
||||
if (is_numeric($date)) {
|
||||
$dateHeader->setDeltaSeconds($date);
|
||||
} else {
|
||||
$dateHeader->setDate($date);
|
||||
}
|
||||
|
||||
return $dateHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set number of seconds
|
||||
*
|
||||
* @param int $delta
|
||||
* @return RetryAfter
|
||||
*/
|
||||
public function setDeltaSeconds($delta)
|
||||
{
|
||||
$this->deltaSeconds = (int) $delta;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of seconds
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDeltaSeconds()
|
||||
{
|
||||
return $this->deltaSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Retry-After';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns date if it's set, or number of seconds
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
return ($this->date === null) ? $this->deltaSeconds : $this->getDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return header line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return 'Retry-After: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Server.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Server.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.38
|
||||
*/
|
||||
class Server implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'server') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Server string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Server';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Server: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
674
vendor/zendframework/zend-http/src/Header/SetCookie.php
vendored
Normal file
674
vendor/zendframework/zend-http/src/Header/SetCookie.php
vendored
Normal file
@@ -0,0 +1,674 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
use DateTime;
|
||||
use Zend\Uri\UriFactory;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.ietf.org/rfc/rfc2109.txt
|
||||
* @see http://www.w3.org/Protocols/rfc2109/rfc2109
|
||||
*/
|
||||
class SetCookie implements MultipleHeaderInterface
|
||||
{
|
||||
/**
|
||||
* Cookie name
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* Cookie value
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $value = null;
|
||||
|
||||
/**
|
||||
* Version
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
protected $version = null;
|
||||
|
||||
/**
|
||||
* Max Age
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
protected $maxAge = null;
|
||||
|
||||
/**
|
||||
* Cookie expiry date
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
protected $expires = null;
|
||||
|
||||
/**
|
||||
* Cookie domain
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $domain = null;
|
||||
|
||||
/**
|
||||
* Cookie path
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $path = null;
|
||||
|
||||
/**
|
||||
* Whether the cookie is secure or not
|
||||
*
|
||||
* @var bool|null
|
||||
*/
|
||||
protected $secure = null;
|
||||
|
||||
/**
|
||||
* If the value need to be quoted or not
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $quoteFieldValue = false;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
protected $httponly = null;
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @param $headerLine
|
||||
* @param bool $bypassHeaderFieldName
|
||||
* @return array|SetCookie
|
||||
*/
|
||||
public static function fromString($headerLine, $bypassHeaderFieldName = false)
|
||||
{
|
||||
static $setCookieProcessor = null;
|
||||
|
||||
if ($setCookieProcessor === null) {
|
||||
$setCookieClass = get_called_class();
|
||||
$setCookieProcessor = function ($headerLine) use ($setCookieClass) {
|
||||
$header = new $setCookieClass;
|
||||
$keyValuePairs = preg_split('#;\s*#', $headerLine);
|
||||
|
||||
foreach ($keyValuePairs as $keyValue) {
|
||||
if (preg_match('#^(?P<headerKey>[^=]+)=\s*("?)(?P<headerValue>[^"]*)\2#', $keyValue, $matches)) {
|
||||
$headerKey = $matches['headerKey'];
|
||||
$headerValue= $matches['headerValue'];
|
||||
} else {
|
||||
$headerKey = $keyValue;
|
||||
$headerValue = null;
|
||||
}
|
||||
|
||||
// First K=V pair is always the cookie name and value
|
||||
if ($header->getName() === null) {
|
||||
$header->setName($headerKey);
|
||||
$header->setValue(urldecode($headerValue));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Process the remaining elements
|
||||
switch (str_replace(['-', '_'], '', 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;
|
||||
default:
|
||||
// Intentionally omitted
|
||||
}
|
||||
}
|
||||
|
||||
return $header;
|
||||
};
|
||||
}
|
||||
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
HeaderValue::assertValid($value);
|
||||
|
||||
// some sites return set-cookie::value, this is to get rid of the second :
|
||||
$name = (strtolower($name) =='set-cookie:') ? 'set-cookie' : $name;
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'set-cookie') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Set-Cookie string: "' . $name . '"');
|
||||
}
|
||||
|
||||
$multipleHeaders = preg_split('#(?<!Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s*#', $value);
|
||||
|
||||
if (count($multipleHeaders) <= 1) {
|
||||
return $setCookieProcessor(array_pop($multipleHeaders));
|
||||
} else {
|
||||
$headers = [];
|
||||
foreach ($multipleHeaders as $headerLine) {
|
||||
$headers[] = $setCookieProcessor($headerLine);
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cookie object constructor
|
||||
*
|
||||
* @todo Add validation of each one of the parameters (legal domain, etc.)
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param int|string|DateTime $expires
|
||||
* @param string $path
|
||||
* @param string $domain
|
||||
* @param bool $secure
|
||||
* @param bool $httponly
|
||||
* @param string $maxAge
|
||||
* @param int $version
|
||||
*/
|
||||
public function __construct(
|
||||
$name = null,
|
||||
$value = null,
|
||||
$expires = null,
|
||||
$path = null,
|
||||
$domain = null,
|
||||
$secure = false,
|
||||
$httponly = false,
|
||||
$maxAge = null,
|
||||
$version = null
|
||||
) {
|
||||
$this->type = 'Cookie';
|
||||
|
||||
$this->setName($name)
|
||||
->setValue($value)
|
||||
->setVersion($version)
|
||||
->setMaxAge($maxAge)
|
||||
->setDomain($domain)
|
||||
->setExpires($expires)
|
||||
->setPath($path)
|
||||
->setSecure($secure)
|
||||
->setHttpOnly($httponly);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string 'Set-Cookie'
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Set-Cookie';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception\RuntimeException
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldValue()
|
||||
{
|
||||
if ($this->getName() == '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$value = urlencode($this->getValue());
|
||||
if ($this->hasQuoteFieldValue()) {
|
||||
$value = '"'. $value . '"';
|
||||
}
|
||||
|
||||
$fieldValue = $this->getName() . '=' . $value;
|
||||
|
||||
$version = $this->getVersion();
|
||||
if ($version !== null) {
|
||||
$fieldValue .= '; Version=' . $version;
|
||||
}
|
||||
|
||||
$maxAge = $this->getMaxAge();
|
||||
if ($maxAge!==null) {
|
||||
$fieldValue .= '; Max-Age=' . $maxAge;
|
||||
}
|
||||
|
||||
$expires = $this->getExpires();
|
||||
if ($expires) {
|
||||
$fieldValue .= '; Expires=' . $expires;
|
||||
}
|
||||
|
||||
$domain = $this->getDomain();
|
||||
if ($domain) {
|
||||
$fieldValue .= '; Domain=' . $domain;
|
||||
}
|
||||
|
||||
$path = $this->getPath();
|
||||
if ($path) {
|
||||
$fieldValue .= '; Path=' . $path;
|
||||
}
|
||||
|
||||
if ($this->isSecure()) {
|
||||
$fieldValue .= '; Secure';
|
||||
}
|
||||
|
||||
if ($this->isHttponly()) {
|
||||
$fieldValue .= '; HttpOnly';
|
||||
}
|
||||
|
||||
return $fieldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return SetCookie
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
HeaderValue::assertValid($name);
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return SetCookie
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set version
|
||||
*
|
||||
* @param int $version
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return SetCookie
|
||||
*/
|
||||
public function setVersion($version)
|
||||
{
|
||||
if ($version !== null && !is_int($version)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid Version number specified');
|
||||
}
|
||||
$this->version = $version;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get version
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Max-Age
|
||||
*
|
||||
* @param int $maxAge
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return SetCookie
|
||||
*/
|
||||
public function setMaxAge($maxAge)
|
||||
{
|
||||
if ($maxAge !== null && (!is_int($maxAge) || ($maxAge < 0))) {
|
||||
throw new Exception\InvalidArgumentException('Invalid Max-Age number specified');
|
||||
}
|
||||
$this->maxAge = $maxAge;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Max-Age
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxAge()
|
||||
{
|
||||
return $this->maxAge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Expires
|
||||
*
|
||||
* @param int|string|DateTime $expires
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function setExpires($expires)
|
||||
{
|
||||
if ($expires === null) {
|
||||
$this->expires = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
if ($expires instanceof DateTime) {
|
||||
$expires = $expires->format(DateTime::COOKIE);
|
||||
}
|
||||
|
||||
$tsExpires = $expires;
|
||||
|
||||
if (is_string($expires)) {
|
||||
$tsExpires = strtotime($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) {
|
||||
$tsExpires = PHP_INT_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_int($tsExpires) || $tsExpires < 0) {
|
||||
throw new Exception\InvalidArgumentException('Invalid expires time specified');
|
||||
}
|
||||
|
||||
$this->expires = $tsExpires;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $inSeconds
|
||||
* @return int|string
|
||||
*/
|
||||
public function getExpires($inSeconds = false)
|
||||
{
|
||||
if ($this->expires === null) {
|
||||
return;
|
||||
}
|
||||
if ($inSeconds) {
|
||||
return $this->expires;
|
||||
}
|
||||
return gmdate('D, d-M-Y H:i:s', $this->expires) . ' GMT';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $domain
|
||||
* @return SetCookie
|
||||
*/
|
||||
public function setDomain($domain)
|
||||
{
|
||||
HeaderValue::assertValid($domain);
|
||||
$this->domain = $domain;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDomain()
|
||||
{
|
||||
return $this->domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return SetCookie
|
||||
*/
|
||||
public function setPath($path)
|
||||
{
|
||||
HeaderValue::assertValid($path);
|
||||
$this->path = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $secure
|
||||
* @return SetCookie
|
||||
*/
|
||||
public function setSecure($secure)
|
||||
{
|
||||
if (null !== $secure) {
|
||||
$secure = (bool) $secure;
|
||||
}
|
||||
$this->secure = $secure;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the value for this cookie should be quoted
|
||||
*
|
||||
* @param bool $quotedValue
|
||||
* @return SetCookie
|
||||
*/
|
||||
public function setQuoteFieldValue($quotedValue)
|
||||
{
|
||||
$this->quoteFieldValue = (bool) $quotedValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSecure()
|
||||
{
|
||||
return $this->secure;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $httponly
|
||||
* @return SetCookie
|
||||
*/
|
||||
public function setHttponly($httponly)
|
||||
{
|
||||
if (null !== $httponly) {
|
||||
$httponly = (bool) $httponly;
|
||||
}
|
||||
$this->httponly = $httponly;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHttponly()
|
||||
{
|
||||
return $this->httponly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the cookie has expired
|
||||
*
|
||||
* Always returns false if the cookie is a session cookie (has no expiry time)
|
||||
*
|
||||
* @param int $now Timestamp to consider as "now"
|
||||
* @return bool
|
||||
*/
|
||||
public function isExpired($now = null)
|
||||
{
|
||||
if ($now === null) {
|
||||
$now = time();
|
||||
}
|
||||
|
||||
if (is_int($this->expires) && $this->expires < $now) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the cookie is a session cookie (has no expiry time set)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSessionCookie()
|
||||
{
|
||||
return ($this->expires === null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the value for this cookie should be quoted
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasQuoteFieldValue()
|
||||
{
|
||||
return $this->quoteFieldValue;
|
||||
}
|
||||
|
||||
public function isValidForRequest($requestDomain, $path, $isSecure = false)
|
||||
{
|
||||
if ($this->getDomain() && (strrpos($requestDomain, $this->getDomain()) === false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->getPath() && (strpos($path, $this->getPath()) !== 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->secure && $this->isSecure()!==$isSecure) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the cookie should be sent or not in a specific scenario
|
||||
*
|
||||
* @param string|\Zend\Uri\Uri $uri URI to check against (secure, domain, path)
|
||||
* @param bool $matchSessionCookies Whether to send session cookies
|
||||
* @param int $now Override the current time when checking for expiry time
|
||||
* @return bool
|
||||
* @throws Exception\InvalidArgumentException If URI does not have HTTP or HTTPS scheme.
|
||||
*/
|
||||
public function match($uri, $matchSessionCookies = true, $now = null)
|
||||
{
|
||||
if (is_string($uri)) {
|
||||
$uri = UriFactory::factory($uri);
|
||||
}
|
||||
|
||||
// Make sure we have a valid Zend_Uri_Http object
|
||||
if (! ($uri->isValid() && ($uri->getScheme() == 'http' || $uri->getScheme() =='https'))) {
|
||||
throw new Exception\InvalidArgumentException('Passed URI is not a valid HTTP or HTTPS URI');
|
||||
}
|
||||
|
||||
// Check that the cookie is secure (if required) and not expired
|
||||
if ($this->secure && $uri->getScheme() != 'https') {
|
||||
return false;
|
||||
}
|
||||
if ($this->isExpired($now)) {
|
||||
return false;
|
||||
}
|
||||
if ($this->isSessionCookie() && ! $matchSessionCookies) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the domain matches
|
||||
if (! self::matchCookieDomain($this->getDomain(), $uri->getHost())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that path matches using prefix match
|
||||
if (! self::matchCookiePath($this->getPath(), $uri->getPath())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we didn't die until now, return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a cookie's domain matches a host name.
|
||||
*
|
||||
* Used by Zend\Http\Cookies for cookie matching
|
||||
*
|
||||
* @param string $cookieDomain
|
||||
* @param string $host
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function matchCookieDomain($cookieDomain, $host)
|
||||
{
|
||||
$cookieDomain = strtolower($cookieDomain);
|
||||
$host = strtolower($host);
|
||||
// Check for either exact match or suffix match
|
||||
return ($cookieDomain == $host ||
|
||||
preg_match('/' . preg_quote($cookieDomain) . '$/', $host));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a cookie's path matches a URL path
|
||||
*
|
||||
* Used by Zend\Http\Cookies for cookie matching
|
||||
*
|
||||
* @param string $cookiePath
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public static function matchCookiePath($cookiePath, $path)
|
||||
{
|
||||
return (strpos($path, $cookiePath) === 0);
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Set-Cookie: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
public function toStringMultipleHeaders(array $headers)
|
||||
{
|
||||
$headerLine = $this->toString();
|
||||
/* @var $header SetCookie */
|
||||
foreach ($headers as $header) {
|
||||
if (!$header instanceof SetCookie) {
|
||||
throw new Exception\RuntimeException(
|
||||
'The SetCookie multiple header implementation can only accept an array of SetCookie headers'
|
||||
);
|
||||
}
|
||||
$headerLine .= "\n" . $header->toString();
|
||||
}
|
||||
return $headerLine;
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/TE.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/TE.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.39
|
||||
*/
|
||||
class TE implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'te') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for TE string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'TE';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'TE: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Trailer.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Trailer.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.40
|
||||
*/
|
||||
class Trailer implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'trailer') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Trailer string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Trailer';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Trailer: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
62
vendor/zendframework/zend-http/src/Header/TransferEncoding.php
vendored
Normal file
62
vendor/zendframework/zend-http/src/Header/TransferEncoding.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.41
|
||||
*/
|
||||
class TransferEncoding implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'transfer-encoding') {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid header line for Transfer-Encoding string: "' . $name . '"'
|
||||
);
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Transfer-Encoding';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Transfer-Encoding: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Upgrade.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Upgrade.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.42
|
||||
*/
|
||||
class Upgrade implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'upgrade') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Upgrade string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Upgrade';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Upgrade: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/UserAgent.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/UserAgent.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
|
||||
*/
|
||||
class UserAgent implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (str_replace(['_', ' ', '.'], '-', strtolower($name)) !== 'user-agent') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for User-Agent string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'User-Agent';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'User-Agent: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Vary.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Vary.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44
|
||||
*/
|
||||
class Vary implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'vary') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Vary string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Vary';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Vary: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Via.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Via.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.45
|
||||
*/
|
||||
class Via implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'via') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Via string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Via';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Via: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
78
vendor/zendframework/zend-http/src/Header/WWWAuthenticate.php
vendored
Normal file
78
vendor/zendframework/zend-http/src/Header/WWWAuthenticate.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.47
|
||||
*/
|
||||
class WWWAuthenticate implements MultipleHeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'www-authenticate') {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid header line for WWW-Authenticate string: "%s"',
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'WWW-Authenticate';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'WWW-Authenticate: ' . $this->getFieldValue();
|
||||
}
|
||||
|
||||
public function toStringMultipleHeaders(array $headers)
|
||||
{
|
||||
$strings = [$this->toString()];
|
||||
foreach ($headers as $header) {
|
||||
if (!$header instanceof WWWAuthenticate) {
|
||||
throw new Exception\RuntimeException(
|
||||
'The WWWAuthenticate multiple header implementation can only'
|
||||
. ' accept an array of WWWAuthenticate headers'
|
||||
);
|
||||
}
|
||||
$strings[] = $header->toString();
|
||||
}
|
||||
return implode("\r\n", $strings);
|
||||
}
|
||||
}
|
60
vendor/zendframework/zend-http/src/Header/Warning.php
vendored
Normal file
60
vendor/zendframework/zend-http/src/Header/Warning.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Http\Header;
|
||||
|
||||
/**
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.46
|
||||
*/
|
||||
class Warning implements HeaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public static function fromString($headerLine)
|
||||
{
|
||||
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
|
||||
|
||||
// check to ensure proper header type for this factory
|
||||
if (strtolower($name) !== 'warning') {
|
||||
throw new Exception\InvalidArgumentException('Invalid header line for Warning string: "' . $name . '"');
|
||||
}
|
||||
|
||||
// @todo implementation details
|
||||
$header = new static($value);
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
if ($value) {
|
||||
HeaderValue::assertValid($value);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldName()
|
||||
{
|
||||
return 'Warning';
|
||||
}
|
||||
|
||||
public function getFieldValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return 'Warning: ' . $this->getFieldValue();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user