Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Respect curl options in CurlClient
Browse files Browse the repository at this point in the history
fixes #362
  • Loading branch information
Art4 committed Dec 11, 2018
1 parent ddc8d82 commit 2ec8d06
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- `YoutubeDownloader\Http\Client::createRequest()` was renamed to `YoutubeDownloader\Http\Client::createFullRequest()`

### Fixed

- CurlClient respects curl options again

### Removed

- `YoutubeDownloader\Http\CurlClient::createRequest()` was removed, use `YoutubeDownloader\Http\CurlClient::createFullRequest()` instead
Expand Down Expand Up @@ -127,7 +131,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- A bug in the downlaoder with adaptive format was fixed
- A bug in the downloader with adaptive format was fixed
- The path to the yearly logs folder was fixed

### Deprecated
Expand Down
11 changes: 7 additions & 4 deletions src/Http/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*/
class CurlClient implements Client /* , ClientInterface, RequestFactoryInterface */
{
private $curlOptions = [];

/**
* Factory for a new fullfeatured Request
*
Expand Down Expand Up @@ -68,7 +70,10 @@ public function createFullRequest($method, $target, array $headers = [], $body =
*/
public function send(RequestInterface $request, array $options = [])
{
$this->sendRequest($request, $options);
// Save curl options in class property, because PSR-18 sendRequest() has no 2nd argument
$this->curlOptions = $this->createCurlOptions($request, $options);

return $this->sendRequest($request);
}

/**
Expand Down Expand Up @@ -103,11 +108,9 @@ private function createRequest($method, $uri)
*/
private function sendRequest(RequestInterface $request)
{
$curl_options = $this->createCurlOptions($request, $options);

$curl_handler = curl_init();

$http_response = $this->getHttpResponseFromCurl($curl_handler, $curl_options);
$http_response = $this->getHttpResponseFromCurl($curl_handler, $this->curlOptions);

curl_close($curl_handler);

Expand Down

0 comments on commit 2ec8d06

Please sign in to comment.