forked from yiisoft/yii2-httpclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransport.php
43 lines (39 loc) · 1.07 KB
/
Transport.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\httpclient;
use yii\base\Component;
use yii\base\Exception;
/**
* Transport performs actual HTTP request sending.
*
* @author Paul Klimov <[email protected]>
* @since 2.0
*/
abstract class Transport extends Component
{
/**
* Performs given request.
* @param Request $request request to be sent.
* @return Response response instance.
* @throws Exception on failure.
*/
abstract public function send($request);
/**
* Performs multiple HTTP requests.
* Particular transport may benefit from this method, allowing sending requests in parallel.
* @param Request[] $requests requests to perform.
* @return Response[] responses list.
*/
public function batchSend(array $requests)
{
$responses = [];
foreach ($requests as $key => $request) {
$responses[$key] = $this->send($request);
}
return $responses;
}
}