File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,9 @@ final class ContentType
1818 public const HTML = 'text/html ' ;
1919 public const TEXT = 'text/plain ' ;
2020 public const JSON = 'application/json ' ;
21- public const XML = 'application/xml ' ;
21+ public const XML = 'application/xml ' ;
2222 public const FORM = 'application/x-www-form-urlencoded ' ;
23+ public const FORM_DATA = 'multipart/form-data ' ;
2324
2425 // Content types mapping
2526 public const TYPES = [
Original file line number Diff line number Diff line change 1111use Swoft \Http \Message \Helper \HttpHelper ;
1212use Swoft \Http \Message \Stream \Stream ;
1313use Swoft \Http \Message \Uri \Uri ;
14+ use Swoft \Stdlib \Helper \Str ;
1415use Swoole \Http \Request as CoRequest ;
1516
1617/**
@@ -311,9 +312,18 @@ public function getParsedBody()
311312 return $ this ->parsedBody ;
312313 }
313314
314-
315315 $ parsedBody = $ this ->coRequest ->post ?? [];
316316
317+ $ needles = [
318+ ContentType::FORM ,
319+ ContentType::FORM_DATA ,
320+ ];
321+ $ contentType = $ this ->getHeaderLine (ContentType::KEY );
322+ if (Str::contains ($ contentType , $ needles )) {
323+ $ this ->parsedBody = $ parsedBody ;
324+ return $ parsedBody ;
325+ }
326+
317327 // Parse body
318328 if (!$ parsedBody && !$ this ->isGet ()) {
319329 $ rawBody = $ this ->getRawBody ();
@@ -323,7 +333,6 @@ public function getParsedBody()
323333 }
324334
325335 $ this ->parsedBody = $ parsedBody ;
326-
327336 return $ this ->parsedBody ;
328337 }
329338
You can’t perform that action at this time.
0 commit comments