1 | <?php |
||
23 | class Client |
||
24 | { |
||
25 | /** |
||
26 | * cURL transport handler. |
||
27 | * |
||
28 | * @var TransportInterface |
||
29 | */ |
||
30 | protected $transport; |
||
31 | |||
32 | /** |
||
33 | * Auto close on error. |
||
34 | * |
||
35 | * @var bool |
||
36 | */ |
||
37 | protected $closeOnError = true; |
||
38 | |||
39 | /** |
||
40 | * @param TransportInterface|null $transport |
||
41 | */ |
||
42 | public function __construct(TransportInterface $transport = null) |
||
46 | |||
47 | /** |
||
48 | * Set transport handler. |
||
49 | * |
||
50 | * @param TransportInterface $transport |
||
51 | */ |
||
52 | public function setTransport(TransportInterface $transport) |
||
56 | |||
57 | /** |
||
58 | * Retrieve transport handler. |
||
59 | * |
||
60 | * @return TransportInterface |
||
61 | */ |
||
62 | public function getTransport() |
||
70 | |||
71 | /** |
||
72 | * Set automatic connection close on error. |
||
73 | * |
||
74 | * @param bool $closeOnError |
||
75 | */ |
||
76 | public function setCloseOnError($closeOnError) |
||
80 | |||
81 | /** |
||
82 | * Check if automatic connection close on error is active. |
||
83 | * |
||
84 | * @return bool |
||
85 | */ |
||
86 | public function isCloseOnError() |
||
90 | |||
91 | /** |
||
92 | * Run PSR7 request. |
||
93 | * |
||
94 | * @param RequestInterface $request |
||
95 | * @param ResponseInterface $response |
||
96 | * |
||
97 | * @throws TransportException |
||
98 | * |
||
99 | * @return ResponseInterface |
||
100 | */ |
||
101 | public function request( |
||
148 | |||
149 | /** |
||
150 | * Get response headers based on transfer information. |
||
151 | * |
||
152 | * @param array $transferHeaders |
||
153 | * @param string $transferContent |
||
154 | * @param array $transferInfo |
||
155 | * |
||
156 | * @return array |
||
157 | */ |
||
158 | protected function getTransferHeaders(array $transferHeaders, $transferContent, array $transferInfo) |
||
178 | |||
179 | /** |
||
180 | * Set response headers and content. |
||
181 | * |
||
182 | * @param ResponseInterface $response |
||
183 | * @param array $headers |
||
184 | * @param string $content |
||
185 | * |
||
186 | * @return ResponseInterface |
||
187 | */ |
||
188 | protected function populateResponse(ResponseInterface $response, array $headers, $content) |
||
209 | } |
||
210 |