1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Ivory Http Adapter package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ivory\HttpAdapter; |
13
|
|
|
|
14
|
|
|
use Ivory\HttpAdapter\Message\MessageFactory; |
15
|
|
|
use Ivory\HttpAdapter\Message\MessageFactoryInterface; |
16
|
|
|
use Ivory\HttpAdapter\Message\MessageInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @author GeLo <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class Configuration implements ConfigurationInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var MessageFactoryInterface |
25
|
|
|
*/ |
26
|
|
|
private $messageFactory; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $protocolVersion = MessageInterface::PROTOCOL_VERSION_1_1; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var bool |
35
|
|
|
*/ |
36
|
|
|
private $keepAlive = false; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var string|null |
40
|
|
|
*/ |
41
|
|
|
private $encodingType; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
private $boundary; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var float |
50
|
|
|
*/ |
51
|
|
|
private $timeout = 10; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
private $userAgent; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param MessageFactoryInterface|null $messageFactory |
60
|
|
|
*/ |
61
|
16223 |
|
public function __construct(MessageFactoryInterface $messageFactory = null) |
62
|
|
|
{ |
63
|
16223 |
|
$this->setMessageFactory($messageFactory ?: new MessageFactory()); |
64
|
16223 |
|
$this->setBoundary(sha1(microtime())); |
65
|
16223 |
|
$this->setUserAgent('Ivory Http Adapter '.HttpAdapterInterface::VERSION); |
66
|
16223 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
15390 |
|
public function getMessageFactory() |
72
|
|
|
{ |
73
|
15390 |
|
return $this->messageFactory; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
16223 |
|
public function setMessageFactory(MessageFactoryInterface $factory) |
80
|
|
|
{ |
81
|
16223 |
|
$this->messageFactory = $factory; |
82
|
16223 |
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
10985 |
|
public function getProtocolVersion() |
88
|
|
|
{ |
89
|
10985 |
|
return $this->protocolVersion; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
4035 |
|
public function setProtocolVersion($protocolVersion) |
96
|
|
|
{ |
97
|
4035 |
|
$this->protocolVersion = $protocolVersion; |
98
|
4035 |
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* {@inheritdoc} |
102
|
|
|
*/ |
103
|
15363 |
|
public function getKeepAlive() |
104
|
|
|
{ |
105
|
15363 |
|
return $this->keepAlive; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* {@inheritdoc} |
110
|
|
|
*/ |
111
|
9 |
|
public function setKeepAlive($keepAlive) |
112
|
|
|
{ |
113
|
9 |
|
$this->keepAlive = $keepAlive; |
114
|
9 |
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* {@inheritdoc} |
118
|
|
|
*/ |
119
|
15354 |
|
public function hasEncodingType() |
120
|
|
|
{ |
121
|
15354 |
|
return $this->encodingType !== null; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* {@inheritdoc} |
126
|
|
|
*/ |
127
|
9 |
|
public function getEncodingType() |
128
|
|
|
{ |
129
|
9 |
|
return $this->encodingType; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* {@inheritdoc} |
134
|
|
|
*/ |
135
|
9 |
|
public function setEncodingType($encodingType) |
136
|
|
|
{ |
137
|
9 |
|
$this->encodingType = $encodingType; |
138
|
9 |
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* {@inheritdoc} |
142
|
|
|
*/ |
143
|
1768 |
|
public function getBoundary() |
144
|
|
|
{ |
145
|
1768 |
|
return $this->boundary; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* {@inheritdoc} |
150
|
|
|
*/ |
151
|
16223 |
|
public function setBoundary($boundary) |
152
|
|
|
{ |
153
|
16223 |
|
$this->boundary = $boundary; |
154
|
16223 |
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* {@inheritdoc} |
158
|
|
|
*/ |
159
|
14634 |
|
public function getTimeout() |
160
|
|
|
{ |
161
|
14634 |
|
return $this->timeout; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* {@inheritdoc} |
166
|
|
|
*/ |
167
|
357 |
|
public function setTimeout($timeout) |
168
|
|
|
{ |
169
|
357 |
|
$this->timeout = $timeout; |
170
|
357 |
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* {@inheritdoc} |
174
|
|
|
*/ |
175
|
15363 |
|
public function getUserAgent() |
176
|
|
|
{ |
177
|
15363 |
|
return $this->userAgent; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* {@inheritdoc} |
182
|
|
|
*/ |
183
|
16223 |
|
public function setUserAgent($userAgent) |
184
|
|
|
{ |
185
|
16223 |
|
$this->userAgent = $userAgent; |
186
|
16223 |
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* {@inheritdoc} |
190
|
|
|
*/ |
191
|
18 |
|
public function hasBaseUri() |
192
|
|
|
{ |
193
|
18 |
|
return $this->messageFactory->hasBaseUri(); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* {@inheritdoc} |
198
|
|
|
*/ |
199
|
9 |
|
public function getBaseUri() |
200
|
|
|
{ |
201
|
9 |
|
return $this->messageFactory->getBaseUri(); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* {@inheritdoc} |
206
|
|
|
*/ |
207
|
9 |
|
public function setBaseUri($baseUri) |
208
|
|
|
{ |
209
|
9 |
|
$this->messageFactory->setBaseUri($baseUri); |
210
|
9 |
|
} |
211
|
|
|
} |
212
|
|
|
|