diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e9fef7d..547d479 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,11 @@ We accept contributions via Pull Requests on [Github](https://github.com/stevenm ## Running Tests ``` bash -$ phpunit +$ ./vendor/bin/phpunit +``` + +``` bash +$ ./vendor/bin/phpcs src --standard=psr2 -sp ``` diff --git a/src/Http.php b/src/Http.php index 8550ab6..2ba52b8 100644 --- a/src/Http.php +++ b/src/Http.php @@ -161,6 +161,25 @@ private function getRequestExceptionParts(RequestException $requestException) return $parts; } + /** + * Creates an array of request options based on the current status of the + * http client. + * + * @return array + */ + protected function getRequestOptions() + { + $options = [ + 'proxy' => Configuration::get('proxy') + ]; + + if (!empty(array_filter($this->multipartResources))) { + $options['multipart'] = $this->multipartResources; + } + + return $options; + } + /** * Creates fully qualified domain from given path. * @@ -230,10 +249,10 @@ protected function queueResourceAs($name, $resource) protected function sendRequest(RequestInterface $request) { try { - $response = $this->httpClient->send($request, [ - 'multipart' => $this->multipartResources, - 'proxy' => Configuration::get('proxy') - ]); + $response = $this->httpClient->send( + $request, + $this->getRequestOptions() + ); $this->multipartResources = [];