作者 karlet

feat:修复ser

@@ -11,6 +11,7 @@ class SimpleRequest @@ -11,6 +11,7 @@ class SimpleRequest
11 public string $method; 11 public string $method;
12 public array $header; 12 public array $header;
13 public array $cookie; 13 public array $cookie;
  14 + public string $rawContent;
14 15
15 public function __construct($data) 16 public function __construct($data)
16 { 17 {
@@ -21,5 +22,14 @@ class SimpleRequest @@ -21,5 +22,14 @@ class SimpleRequest
21 $this->method = $data['method']; 22 $this->method = $data['method'];
22 $this->header = $data['header']; 23 $this->header = $data['header'];
23 $this->cookie = $data['cookie']; 24 $this->cookie = $data['cookie'];
  25 + $this->rawContent = $data['rawContent'];
  26 + if ($this->method == 'POST') {
  27 + if (count($this->post) == 0) {
  28 + $data = json_decode($this->rawContent, true);
  29 + if ($data) {
  30 + $this->post = $data;
  31 + }
  32 + }
  33 + }
24 } 34 }
25 } 35 }
@@ -40,6 +40,7 @@ class SimpleServerCoroutine @@ -40,6 +40,7 @@ class SimpleServerCoroutine
40 'method' => $request->getMethod(), 40 'method' => $request->getMethod(),
41 'header' => $request->header ?: [], 41 'header' => $request->header ?: [],
42 'cookie' => $request->cookie ?: [], 42 'cookie' => $request->cookie ?: [],
  43 + 'rawContent' => $request->rawContent() ?: ''
43 ]; 44 ];
44 $simpleRequest = new SimpleRequest($requestInfo); 45 $simpleRequest = new SimpleRequest($requestInfo);
45 $res = call_user_func($callback, $simpleRequest); 46 $res = call_user_func($callback, $simpleRequest);