* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class Message implements MessageInterface { /** @var array */ protected $headers; /** @var \Psr\Http\Message\StreamInterface */ protected $body; /** @var string */ protected $protocol; /** * @param array $headers * @param \Psr\Http\Message\StreamInterface|string|resource $body */ public function __construct(array $headers = array(), $body = null) { $this->headers = $this->prepareHeaders($headers); $this->body = $this->prepareBody($body); } public function getProtocolVersion() { return $this->protocol; } public function setProtocolVersion($protocol) { $this->protocol = $protocol; } public function getHeaders() { return $this->headers; } public function setHeaders(array $headers) { $this->headers = $this->prepareHeaders($headers); } public function hasHeader($name) { return array_key_exists(strtolower($name), $this->headers); } public function getHeader($name) { $lines = $this->getHeaderLines($name); return $lines ? implode(', ', $lines) : null; } public function getHeaderLines($name) { $name = strtolower($name); if (!$this->hasHeader($name)) { return array(); } return $this->headers[$name]; } public function setHeader($name, $value) { $this->headers[strtolower($name)] = $this->normalizeHeaderValue($value); } public function addHeader($name, $value) { $name = strtolower($name); if ($this->hasHeader($name)) { $this->setHeader($name, array_merge($this->headers[$name], $this->normalizeHeaderValue($value))); } else { $this->setHeader($name, $value); } } public function removeHeader($name) { $name = strtolower($name); if ($this->hasHeader($name)) { unset($this->headers[$name]); } } public function getBody() { return $this->body; } public function setBody(PsrStreamInterface $body) { $this->body = $body; } protected function prepareHeaders(array $headers) { return array_map(array($this, 'normalizeHeaderValue'), array_change_key_case($headers)); } protected function normalizeHeaderValue($value) { return is_array($value) ? array_map('strval', $value) : [(string) $value]; } protected function prepareBody($body) { if ($body instanceof PsrStreamInterface) { return $body; } elseif ($body === null) { return new Stream\StringStream(); } elseif (is_string($body)) { return new Stream\StringStream($body); } elseif (is_resource($body)) { return new Stream\TempStream($body); } else { throw new InvalidArgumentException('Body must be either a PSX\Http\StreamInterface, string or resource'); } } } __halt_compiler();----SIGNATURE:----rq5SzZErJNWwjabHhtuvmzsddX8nr73zT7vPwSPHMhwkveW1w7e4PeBi9KguFn3hk/Iir85ULKLT/SaPSCOuQ2tjyWbDFCntSTKwVZzU1nlygYwIEGIIpzsWNuEeKH4CEFpAB1+f6b4f3QOM5KQ2BsczNAwlCG3R8XnCGxDxN+2NNabzljNrCpno1eT9SkNM71Rpc3fxQ+Ps7F5dFV0ki6v4Xlco5S709HNA6hw6UnWCrjkSbmpxCFG2rJW2cc66dxpZO7llMazZQGh4vlF+hIqGq/oBKyj5pohrwaLYODMehjxqHwJYs79iX7/nu1CK6wjIHpFuuUxfUqFzx6a8yHMrZ+4ZENboro+9DdOTUnFzRN7EskH9WnBES6HziPGHados+FvGfUclW80rcFr7u5yYkTesOWEVkhshoGK/UhAyG4d7lLqWSH6IV8+LqLWS16i9EZIuc3pPNxOhnL7R2PI40TTKjnH7S4y/LVHKWtCmSJoVpHNE6Wxo8ETV4UQ4ptfWeB+rVfumpvX0OIRsZ300GNTJNDE/QRDjPc2ux7DZs80sN/XwUytIHQTx6wwOi6y608Jed3MMk/6N2E8Hww0IHBPhcs83zPqzdfjgPRcqB0hoO0gFH3SQ+v8DLJnleuwSHBl7qUaEWzpcF7bUxPKQLPObyfXjfuExvlNKLyo=----ATTACHMENT:----MzE3NTM2NTY2MzI4ODc0NiAyMjA1NzkzMzc1NDkyNTM3IDE0NDcwMjg3NTg5NDE0NTM=