Skip to content

Commit

Permalink
Merge pull request #24 from ins0/fix/23
Browse files Browse the repository at this point in the history
Fix: removed http client reuse instance
  • Loading branch information
EvanDotPro committed Jan 27, 2015
2 parents 0e66a56 + aec202d commit 077b1e2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/EdpGithub/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ public function request($path, array $parameters = array(), $httpMethod = 'GET',
{
$client = $this->getHttpClient($path);
$request = $client->getRequest();
$client->setMethod($httpMethod);

if ($httpMethod == 'GET') {
$query = $request->getQuery();
foreach ($parameters as $key => $value) {
$query->set($key, $value);
}
} elseif ($httpMethod == 'POST') {
$client->setMethod($httpMethod);
$request->setContent(json_encode($parameters));
}

Expand Down Expand Up @@ -150,10 +150,8 @@ public function request($path, array $parameters = array(), $httpMethod = 'GET',
*/
public function getHttpClient($path)
{
if (null === $this->httpClient) {
$this->httpClient = new HttpClient();
$this->httpClient->setAdapter($this->getHttpAdapter());
}
$this->httpClient = new HttpClient();
$this->httpClient->setAdapter($this->getHttpAdapter());
$this->httpClient->setUri($this->options['base_url'] . $path);
return $this->httpClient;
}
Expand Down

0 comments on commit 077b1e2

Please sign in to comment.