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

Commit

Permalink
Merge branch 'develop' of git://github.com/zendframework/zf2 into string
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 191 changed files with 4,192 additions and 1,995 deletions.
4 changes: 2 additions & 2 deletions composer.json
@@ -1,6 +1,6 @@
{
"name": "zendframework/zend-http",
"description": "provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests",
"description": "provides an easy interface for preforming Hyper-Text Transfer Protocol (HTTP) requests",
"license": "BSD-3-Clause",
"keywords": [
"zf2",
Expand All @@ -9,7 +9,7 @@
"homepage": "https://github.com/zendframework/zend-http",
"autoload": {
"psr-4": {
"Zend\\Http": "src/"
"Zend\\Http\\": "src/"
}
},
"require": {
Expand Down
108 changes: 108 additions & 0 deletions src/AbstractMessage.php
@@ -0,0 +1,108 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Http
*/

namespace Zend\Http;

use Zend\Stdlib\Message;

/**
* HTTP standard message (Request/Response)
*
* @category Zend
* @package Zend_Http
* @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4
*/
abstract class AbstractMessage extends Message
{
/**#@+
* @const string Version constant numbers
*/
const VERSION_10 = '1.0';
const VERSION_11 = '1.1';
/**#@-*/

/**
* @var string
*/
protected $version = self::VERSION_11;

/**
* @var Headers|null
*/
protected $headers = null;

/**
* Set the HTTP version for this object, one of 1.0 or 1.1
* (AbstractMessage::VERSION_10, AbstractMessage::VERSION_11)
*
* @param string $version (Must be 1.0 or 1.1)
* @return AbstractMessage
* @throws Exception\InvalidArgumentException
*/
public function setVersion($version)
{
if ($version != self::VERSION_10 && $version != self::VERSION_11) {
throw new Exception\InvalidArgumentException(
'Not valid or not supported HTTP version: ' . $version
);
}
$this->version = $version;
return $this;
}

/**
* Return the HTTP version for this request
*
* @return string
*/
public function getVersion()
{
return $this->version;
}

/**
* Provide an alternate Parameter Container implementation for headers in this object,
* (this is NOT the primary API for value setting, for that see getHeaders())
*
* @see getHeaders()
* @param Headers $headers
* @return AbstractMessage
*/
public function setHeaders(Headers $headers)
{
$this->headers = $headers;
return $this;
}

/**
* Return the header container responsible for headers
*
* @return Headers
*/
public function getHeaders()
{
if ($this->headers === null || is_string($this->headers)) {
// this is only here for fromString lazy loading
$this->headers = (is_string($this->headers)) ? Headers::fromString($this->headers) : new Headers();
}

return $this->headers;
}

/**
* Allow PHP casting of this object
*
* @return string
*/
public function __toString()
{
return $this->toString();
}
}

0 comments on commit be511e2

Please sign in to comment.