Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

Commit 536739a

Browse files
committed
Better support for cURL streams.
1 parent e6e5a6f commit 536739a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Billogram/Api.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ private function httpRequest(
231231
$streamParams['http']['content'] = $data;
232232
}
233233

234+
$streamParams['cURL'] = $streamParams['http'];
235+
234236
$context = stream_context_create($streamParams);
235237
$fp = @fopen($url, 'rb', false, $context);
236238
if (!$fp)
@@ -244,7 +246,11 @@ private function httpRequest(
244246

245247
if ($content !== false) {
246248
$metadata = stream_get_meta_data($fp);
247-
foreach ($metadata['wrapper_data'] as $row) {
249+
if (isset($metadata['wrapper_data']['headers']))
250+
$headerMetadata = $metadata['wrapper_data']['headers'];
251+
else
252+
$headerMetadata = $metadata['wrapper_data'];
253+
foreach ($headerMetadata as $row) {
248254
if (preg_match('/^HTTP\/1\.[01] (\d{3})\s*(.*)/', $row, $m)) {
249255
$statusCode = $m[1];
250256
$status = $m[2];

0 commit comments

Comments
 (0)