Skip to content

Commit

Permalink
return raw response rather than streaming response
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdankharchenko committed Mar 13, 2021
1 parent a48cc1a commit 53b8219
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -24,7 +23,7 @@ public function __construct(array $data)
}

/**
* @return ConversionResponse|\Symfony\Component\HttpFoundation\StreamedResponse|null
* @return ConversionResponse|Response
* @throws ApiErrorException
*/
public function post()
Expand All @@ -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)
Expand All @@ -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));
Expand Down
5 changes: 3 additions & 2 deletions src/Capturely.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -190,7 +191,7 @@ public function serializePayload()
}

/**
* @return Responses\ConversionResponse|\Symfony\Component\HttpFoundation\StreamedResponse|null
* @return Responses\ConversionResponse|Response
* @throws ApiErrorException
*/
public function stream()
Expand All @@ -201,7 +202,7 @@ public function stream()
}

/**
* @return Responses\ConversionResponse|\Symfony\Component\HttpFoundation\StreamedResponse|null
* @return Responses\ConversionResponse|Response
* @throws ApiErrorException
*/
public function capture()
Expand Down

0 comments on commit 53b8219

Please sign in to comment.