Skip to content

Commit

Permalink
Update request options to exclude multipart when irrelevant
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmaguire committed Mar 23, 2017
1 parent 070015e commit 50a9e62
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```


Expand Down
27 changes: 23 additions & 4 deletions src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 = [];

Expand Down

0 comments on commit 50a9e62

Please sign in to comment.