Skip to content

Commit 955c977

Browse files
[HttpClient] turn exception into log when the request has no content-type
1 parent ae3a9cd commit 955c977

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Response/NativeResponse.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,18 @@ public function __destruct()
109109

110110
private function open(): void
111111
{
112-
set_error_handler(function ($type, $msg) { throw new TransportException($msg); });
112+
$url = $this->url;
113+
114+
set_error_handler(function ($type, $msg) use (&$url) {
115+
if (E_NOTICE !== $type || 'fopen(): Content-type not specified assuming application/x-www-form-urlencoded' !== $msg) {
116+
throw new TransportException($msg);
117+
}
118+
119+
$this->logger && $this->logger->info(sprintf('%s for "%s".', $msg, $url ?? $this->url));
120+
});
113121

114122
try {
115123
$this->info['start_time'] = microtime(true);
116-
$url = $this->url;
117124

118125
while (true) {
119126
$context = stream_context_get_options($this->context);

0 commit comments

Comments
 (0)