From cf84d70ca17420eaea2923f226d9d7d7250d7ebe Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 23 Apr 2023 00:40:03 +0900 Subject: [PATCH] Also recognize Content-Type headers with optional parameters --- common/framework/HTTP.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/framework/HTTP.php b/common/framework/HTTP.php index d76ea261b..ac5f7ae2b 100644 --- a/common/framework/HTTP.php +++ b/common/framework/HTTP.php @@ -129,18 +129,16 @@ class HTTP } elseif (is_array($data) && count($data) > 0) { - if (isset($headers['Content-Type']) && $headers['Content-Type'] === 'multipart/form-data') + if (isset($headers['Content-Type']) && preg_match('!^multipart/form-data\b!i', $headers['Content-Type'])) { - unset($headers['Content-Type']); $settings['multipart'] = []; foreach ($data as $key => $val) { $settings['multipart'][] = ['name' => $key, 'contents' => $val]; } } - elseif (isset($headers['Content-Type']) && $headers['Content-Type'] === 'application/json') + elseif (isset($headers['Content-Type']) && preg_match('!^application/json\b!i', $headers['Content-Type'])) { - unset($headers['Content-Type']); $settings['json'] = $data; } elseif ($method !== 'GET')