use GuzzleHttp\RequestOptions;
use mattwright\URLResolver;
use Psr\Http\Message\ResponseInterface;
+use Psr\Log\InvalidArgumentException;
use Psr\Log\LoggerInterface;
/**
$header = [];
if (!empty($opts['accept_content'])) {
- array_push($header, 'Accept: ' . $opts['accept_content']);
+ $header['Accept'] = $opts['accept_content'];
}
if (!empty($opts['header'])) {
try {
switch ($method) {
case 'get':
- $response = $this->client->get($url, $conf);
- break;
case 'head':
- $response = $this->client->head($url, $conf);
+ case 'post':
+ $response = $this->client->$method($url, $conf);
break;
default:
throw new TransferException('Invalid method');
} else {
return new CurlResult($url, '', ['http_code' => $exception->getCode()], $exception->getCode(), '');
}
+ } catch (InvalidArgumentException $argumentException) {
+ $this->logger->info('Invalid Argument for HTTP call.', ['url' => $url, 'method' => $method, 'exception' => $argumentException]);
+ return new CurlResult($url, '', ['http_code' => $argumentException->getCode()], $argumentException->getCode(), $argumentException->getMessage());
} finally {
$this->logger->debug('Request stop.', ['url' => $url, 'method' => $method]);
$this->profiler->stopRecording();