12
12
use Http \Message \MessageFactoryAwareTemplate ;
13
13
use Http \Message \StreamFactory ;
14
14
use Http \Message \StreamFactoryAwareTemplate ;
15
- use InvalidArgumentException ;
16
15
use Psr \Http \Message \RequestInterface ;
17
16
use Psr \Http \Message \ResponseInterface ;
18
- use RuntimeException ;
19
- use UnexpectedValueException ;
20
17
21
18
/**
22
- * Use php cURL extension to perform HTTP requests
23
- *
24
19
* @author Kemist <kemist1980@gmail.com>
25
20
* @author Михаил Красильников <m.krasilnikov@yandex.ru>
26
21
* @author Blake Williams <github@shabbyrobe.org>
@@ -98,8 +93,8 @@ public function __destruct()
98
93
*
99
94
* @return ResponseInterface
100
95
*
101
- * @throws UnexpectedValueException if unsupported HTTP version requested
102
- * @throws InvalidArgumentException
96
+ * @throws \ UnexpectedValueException if unsupported HTTP version requested
97
+ * @throws \ InvalidArgumentException
103
98
* @throws RequestException
104
99
*
105
100
* @since 1.00
@@ -110,7 +105,7 @@ public function sendRequest(RequestInterface $request)
110
105
111
106
try {
112
107
$ this ->request ($ options , $ raw , $ info );
113
- } catch (RuntimeException $ e ) {
108
+ } catch (\ RuntimeException $ e ) {
114
109
throw new RequestException ($ e ->getMessage (), $ request , $ e );
115
110
}
116
111
@@ -168,7 +163,7 @@ public function sendRequest(RequestInterface $request)
168
163
* @param string $raw raw response
169
164
* @param array $info cURL response info
170
165
*
171
- * @throws RuntimeException on cURL error
166
+ * @throws \ RuntimeException on cURL error
172
167
*
173
168
* @since 1.00
174
169
*/
@@ -184,7 +179,7 @@ protected function request($options, &$raw, &$info)
184
179
$ raw = curl_exec ($ this ->handle );
185
180
186
181
if (curl_errno ($ this ->handle ) > 0 ) {
187
- throw new RuntimeException (
182
+ throw new \ RuntimeException (
188
183
sprintf (
189
184
'Curl error: (%d) %s ' ,
190
185
curl_errno ($ this ->handle ),
@@ -200,7 +195,7 @@ protected function request($options, &$raw, &$info)
200
195
*
201
196
* @param RequestInterface $request
202
197
*
203
- * @throws UnexpectedValueException if unsupported HTTP version requested
198
+ * @throws \ UnexpectedValueException if unsupported HTTP version requested
204
199
*
205
200
* @return array
206
201
*/
@@ -220,7 +215,7 @@ private function createCurlOptions(RequestInterface $request)
220
215
$ options [CURLOPT_TIMEOUT ] = $ this ->settings ['timeout ' ];
221
216
222
217
if (in_array ($ request ->getMethod (), ['OPTIONS ' , 'POST ' , 'PUT ' ], true )) {
223
- /* cURL allows request body only for these methods. */
218
+ // cURL allows request body only for these methods.
224
219
$ body = (string ) $ request ->getBody ();
225
220
if ('' !== $ body ) {
226
221
$ options [CURLOPT_POSTFIELDS ] = $ body ;
@@ -230,7 +225,7 @@ private function createCurlOptions(RequestInterface $request)
230
225
if ($ request ->getMethod () === 'HEAD ' ) {
231
226
$ options [CURLOPT_NOBODY ] = true ;
232
227
} elseif ($ request ->getMethod () !== 'GET ' ) {
233
- /* GET is a default method. Other methods should be specified explicitly. */
228
+ // GET is a default method. Other methods should be specified explicitly.
234
229
$ options [CURLOPT_CUSTOMREQUEST ] = $ request ->getMethod ();
235
230
}
236
231
@@ -248,7 +243,7 @@ private function createCurlOptions(RequestInterface $request)
248
243
*
249
244
* @param string $requestVersion
250
245
*
251
- * @throws UnexpectedValueException if unsupported version requested
246
+ * @throws \ UnexpectedValueException if unsupported version requested
252
247
*
253
248
* @return int
254
249
*/
@@ -263,7 +258,7 @@ private function getProtocolVersion($requestVersion)
263
258
if (defined ('CURL_HTTP_VERSION_2_0 ' )) {
264
259
return CURL_HTTP_VERSION_2_0 ;
265
260
}
266
- throw new UnexpectedValueException ('libcurl 7.33 needed for HTTP 2.0 support ' );
261
+ throw new \ UnexpectedValueException ('libcurl 7.33 needed for HTTP 2.0 support ' );
267
262
}
268
263
return CURL_HTTP_VERSION_NONE ;
269
264
}
0 commit comments