~ballot/wordpress/openstack-objectstorage-breaking-insight

« back to all changes in this revision

Viewing changes to src/OpenStack/Common/Transport/MessageInterface.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/*
 
4
 * (c) Copyright 2014 Rackspace US, Inc.
 
5
 *
 
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
 
9
 *
 
10
 *      http://www.apache.org/licenses/LICENSE-2.0
 
11
 *
 
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
 
16
 * under the License.
 
17
 */
 
18
 
 
19
namespace OpenStack\Common\Transport;
 
20
 
 
21
/**
 
22
 * HTTP messages consist of requests from a client to a server and responses
 
23
 * from a server to a client.
 
24
 *
 
25
 * @link https://github.com/php-fig/fig-standards/blob/master/proposed/http-message.md#31-psrhttpmessageinterface
 
26
 */
 
27
interface MessageInterface
 
28
{
 
29
    /**
 
30
     * Gets the HTTP protocol version.
 
31
     *
 
32
     * @return string HTTP protocol version.
 
33
     */
 
34
    public function getProtocolVersion();
 
35
 
 
36
    /**
 
37
     * Gets the body of the message.
 
38
     *
 
39
     * @return StreamInterface|null Returns the body, or null if not set.
 
40
     */
 
41
    public function getBody();
 
42
 
 
43
    /**
 
44
     * Sets the body of the message.
 
45
     *
 
46
     * The body MUST be a StreamInterface object. Setting the body to null MUST
 
47
     * remove the existing body.
 
48
     *
 
49
     * @param StreamInterface|null $body Body.
 
50
     *
 
51
     * @return self Returns the message.
 
52
     *
 
53
     * @throws \InvalidArgumentException When the body is not valid.
 
54
     */
 
55
    public function setBody(/* StreamInterface */ $body = null);
 
56
 
 
57
    /**
 
58
     * Gets all message headers.
 
59
     *
 
60
     * The keys represent the header name as it will be sent over the wire, and
 
61
     * each value is an array of strings associated with the header.
 
62
     *
 
63
     *     // Represent the headers as a string
 
64
     *     foreach ($message->getHeaders() as $name => $values) {
 
65
     *         echo $name . ": " . implode(", ", $values);
 
66
     *     }
 
67
     *
 
68
     * @return array Returns an associative array of the message's headers.
 
69
     */
 
70
    public function getHeaders();
 
71
 
 
72
    /**
 
73
     * Checks if a header exists by the given case-insensitive name.
 
74
     *
 
75
     * @param string $header Case-insensitive header name.
 
76
     *
 
77
     * @return bool Returns true if any header names match the given header
 
78
     *     name using a case-insensitive string comparison. Returns false if
 
79
     *     no matching header name is found in the message.
 
80
     */
 
81
    public function hasHeader($header);
 
82
 
 
83
    /**
 
84
     * Retrieve a header by the given case-insensitive name.
 
85
     *
 
86
     * By default, this method returns all of the header values of the given
 
87
     * case-insensitive header name as a string concatenated together using
 
88
     * a comma. Because some header should not be concatenated together using a
 
89
     * comma, this method provides a Boolean argument that can be used to
 
90
     * retrieve the associated header values as an array of strings.
 
91
     *
 
92
     * @param string $header  Case-insensitive header name.
 
93
     * @param bool   $asArray Set to true to retrieve the header value as an
 
94
     *                        array of strings.
 
95
     *
 
96
     * @return array|string
 
97
     */
 
98
    public function getHeader($header, $asArray = false);
 
99
 
 
100
    /**
 
101
     * Sets a header, replacing any existing values of any headers with the
 
102
     * same case-insensitive name.
 
103
     *
 
104
     * The header values MUST be a string or an array of strings.
 
105
     *
 
106
     * @param string       $header Header name
 
107
     * @param string|array $value  Header value(s)
 
108
     *
 
109
     * @return self Returns the message.
 
110
     */
 
111
    public function setHeader($header, $value);
 
112
 
 
113
    /**
 
114
     * Sets headers, replacing any headers that have already been set on the
 
115
     * message.
 
116
     *
 
117
     * The array keys MUST be a string. The array values must be either a
 
118
     * string or an array of strings.
 
119
     *
 
120
     * @param array $headers Headers to set.
 
121
     *
 
122
     * @return self Returns the message.
 
123
     */
 
124
    public function setHeaders(array $headers);
 
125
 
 
126
    /**
 
127
     * Appends a header value to any existing values associated with the
 
128
     * given header name.
 
129
     *
 
130
     * @param string $header Header name to add
 
131
     * @param string $value  Value of the header
 
132
     *
 
133
     * @return self
 
134
     */
 
135
    public function addHeader($header, $value);
 
136
 
 
137
    /**
 
138
     * Merges in an associative array of headers.
 
139
     *
 
140
     * Each array key MUST be a string representing the case-insensitive name
 
141
     * of a header. Each value MUST be either a string or an array of strings.
 
142
     * For each value, the value is appended to any existing header of the same
 
143
     * name, or, if a header does not already exist by the given name, then the
 
144
     * header is added.
 
145
     *
 
146
     * @param array $headers Associative array of headers to add to the message
 
147
     *
 
148
     * @return self
 
149
     */
 
150
    public function addHeaders(array $headers);
 
151
 
 
152
    /**
 
153
     * Remove a specific header by case-insensitive name.
 
154
     *
 
155
     * @param string $header HTTP header to remove
 
156
     *
 
157
     * @return self
 
158
     */
 
159
    public function removeHeader($header);
 
160
}
 
 
b'\\ No newline at end of file'