4
* (c) Copyright 2014 Rackspace US, Inc.
6
* Licensed under the Apache License, Version 2.0 (the "License"); you may
7
* not use this file except in compliance with the License. You may obtain
8
* a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
* License for the specific language governing permissions and limitations
19
namespace OpenStack\Common\Transport\Guzzle;
21
use OpenStack\Common\Transport\MessageInterface;
22
use GuzzleHttp\Message\MessageInterface as GuzzleMessageInterface;
25
* An adapter class which wraps {@see GuzzleHttp\Message\MessageInterface}
26
* objects. Until PSR releases a standardised interface that all projects can
27
* share, we need to adapt the different interfaces.
29
* As you will notice, most of this adapter is a like-for-like method
30
* translation. Although it seems verbose, it is actually a lot more explicit,
31
* clearer and easier to debug than using magic methods.
33
class MessageAdapter implements MessageInterface
35
/** @var \GuzzleHttp\Message\MessageInterface The Guzzle message being wrapped */
39
* @param \GuzzleHttp\Message\MessageInterface $guzzleMessage
41
public function __construct(GuzzleMessageInterface $guzzleMessage)
43
$this->setMessage($guzzleMessage);
47
* This sets the Guzzle object being wrapped.
49
* @param \GuzzleHttp\Message\MessageInterface $guzzleMessage The object being wrapped.
51
public function setMessage(GuzzleMessageInterface $guzzleMessage)
53
$this->message = $guzzleMessage;
57
* @return \GuzzleHttp\Message\MessageInterface
59
public function getMessage()
61
return $this->message;
64
public function getProtocolVersion()
66
return $this->message->getProtocolVersion();
69
public function getBody()
71
return $this->message->getBody();
74
public function setBody(/* StreamInterface */ $body = null)
76
$this->message->setBody($body);
79
public function getHeaders()
81
return $this->message->getHeaders();
84
public function hasHeader($header)
86
return $this->message->hasHeader($header);
89
public function getHeader($header, $asArray = false)
91
return $this->message->getHeader($header, $asArray);
94
public function setHeader($header, $value)
96
$this->message->setHeader($header, $value);
99
public function setHeaders(array $headers)
101
$this->message->setHeaders($headers);
104
public function addHeader($header, $value)
106
$this->message->addHeader($header, $value);
109
public function addHeaders(array $headers)
111
$this->message->addHeaders($headers);
114
public function removeHeader($header)
116
$this->message->removeHeader($header);
b'\\ No newline at end of file'