Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 396da37

Browse filesBrowse files
bug #34669 [HttpClient] turn exception into log when the request has no content-type (nicolas-grekas)
This PR was merged into the 4.3 branch. Discussion ---------- [HttpClient] turn exception into log when the request has no content-type | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Spotted while merging a PR with ext-curl disabled: ``` [Symfony\Component\HttpClient\Exception\TransportException] fopen(): Content-type not specified assuming application/x-www-form-urlencoded ``` This is now a log. Commits ------- 4c671a4 [HttpClient] turn exception into log when the request has no content-type
2 parents 3f13e8e + 4c671a4 commit 396da37
Copy full SHA for 396da37

File tree

1 file changed

+9
-2
lines changed
Filter options

1 file changed

+9
-2
lines changed

‎src/Symfony/Component/HttpClient/Response/NativeResponse.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Response/NativeResponse.php
+9-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.