Skip to content

Commit

Permalink
reduce amount of code in client, reduce timeout to 50ms for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat authored and Patrick committed Jan 14, 2021
1 parent c85e373 commit dc7ea0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
26 changes: 1 addition & 25 deletions src/UrlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,7 @@ protected function getCurlHandleForUrl(string $method, string $url)
curl_setopt($curlHandle, CURLINFO_HEADER_OUT, true);
curl_setopt($curlHandle, CURLOPT_FAILONERROR, true);

$method = strtolower($method);

if ($method === 'delete') {
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'DELETE');
}

if ($method === 'head') {
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'HEAD');
}

if ($method === 'options') {
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'OPTIONS');
}

if ($method === 'patch') {
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'PATCH');
}

if ($method === 'post') {
curl_setopt($curlHandle, CURLOPT_POST, true);
}

if ($method === 'put') {
curl_setopt($curlHandle, CURLOPT_PUT, true);
}
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, strtoupper($method));

return $curlHandle;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/UrlClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function it_retrieves_urls(): void
$client = new UrlClient();

foreach ($methods as $method => $timeoutMs) {
$client->timeoutMs = 150;
$client->timeoutMs = 50;

$result = $client->retrieve($method, 'http://localhost:23517/');

Expand Down

0 comments on commit dc7ea0b

Please sign in to comment.