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

Commit

Permalink
Better support for cURL streams.
Browse files Browse the repository at this point in the history
  • Loading branch information
kalaspuff committed Feb 6, 2014
1 parent e6e5a6f commit 536739a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Billogram/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ private function httpRequest(
$streamParams['http']['content'] = $data;
}

$streamParams['cURL'] = $streamParams['http'];

$context = stream_context_create($streamParams);
$fp = @fopen($url, 'rb', false, $context);
if (!$fp)
Expand All @@ -244,7 +246,11 @@ private function httpRequest(

if ($content !== false) {
$metadata = stream_get_meta_data($fp);
foreach ($metadata['wrapper_data'] as $row) {
if (isset($metadata['wrapper_data']['headers']))
$headerMetadata = $metadata['wrapper_data']['headers'];
else
$headerMetadata = $metadata['wrapper_data'];
foreach ($headerMetadata as $row) {
if (preg_match('/^HTTP\/1\.[01] (\d{3})\s*(.*)/', $row, $m)) {
$statusCode = $m[1];
$status = $m[2];
Expand Down

0 comments on commit 536739a

Please sign in to comment.