From 53b8219ad62b04aff4bcba7bacb467dd62750c88 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Sat, 13 Mar 2021 16:54:22 -0500 Subject: [PATCH] return raw response rather than streaming response --- src/Api.php | 12 ++++-------- src/Capturely.php | 5 +++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Api.php b/src/Api.php index 588ee79..bf00e8d 100644 --- a/src/Api.php +++ b/src/Api.php @@ -10,7 +10,6 @@ use Illuminate\Http\Client\Response; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Http; -use Illuminate\Support\Facades\Response as ResponseFacade; class Api { @@ -24,7 +23,7 @@ public function __construct(array $data) } /** - * @return ConversionResponse|\Symfony\Component\HttpFoundation\StreamedResponse|null + * @return ConversionResponse|Response * @throws ApiErrorException */ public function post() @@ -33,7 +32,8 @@ public function post() } /** - * @return ConversionResponse|\Symfony\Component\HttpFoundation\StreamedResponse|null + * @param Response $response + * @return ConversionResponse|Response * @throws ApiErrorException */ protected function parseResponse(Response $response) @@ -43,11 +43,7 @@ protected function parseResponse(Response $response) } if ($this->isStream()) { - return ResponseFacade::stream(function() use ($response) { - echo $response->body(); - }, 200, [ - 'Content-Type' => $response->header('Content-Type'), - ]); + return $response; } return new ConversionResponse(json_decode($response->body(), true)); diff --git a/src/Capturely.php b/src/Capturely.php index 85fae58..e8b945f 100644 --- a/src/Capturely.php +++ b/src/Capturely.php @@ -6,6 +6,7 @@ use Capturely\Structures\Pdf; use Capturely\Structures\Screenshot; use Closure; +use Illuminate\Http\Client\Response; use Illuminate\Support\Traits\ReflectsClosures; use RuntimeException; @@ -190,7 +191,7 @@ public function serializePayload() } /** - * @return Responses\ConversionResponse|\Symfony\Component\HttpFoundation\StreamedResponse|null + * @return Responses\ConversionResponse|Response * @throws ApiErrorException */ public function stream() @@ -201,7 +202,7 @@ public function stream() } /** - * @return Responses\ConversionResponse|\Symfony\Component\HttpFoundation\StreamedResponse|null + * @return Responses\ConversionResponse|Response * @throws ApiErrorException */ public function capture()