[HttpClient] turn exception into log when the request has no content-type

This commit is contained in:
Nicolas Grekas 2019-11-27 23:48:43 +01:00
parent 74cfa364c0
commit 4c671a4487

View File

@ -109,11 +109,18 @@ final class NativeResponse implements ResponseInterface
private function open(): void
{
set_error_handler(function ($type, $msg) { throw new TransportException($msg); });
$url = $this->url;
set_error_handler(function ($type, $msg) use (&$url) {
if (E_NOTICE !== $type || 'fopen(): Content-type not specified assuming application/x-www-form-urlencoded' !== $msg) {
throw new TransportException($msg);
}
$this->logger && $this->logger->info(sprintf('%s for "%s".', $msg, $url ?? $this->url));
});
try {
$this->info['start_time'] = microtime(true);
$url = $this->url;
while (true) {
$context = stream_context_get_options($this->context);