Ver Fonte

Make Http Request supports application/json

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
Jack Cherng há 5 anos atrás
pai
commit
7ba4aca421
1 ficheiros alterados com 5 adições e 1 exclusões
  1. 5 1
      Protocols/Http/Request.php

+ 5 - 1
Protocols/Http/Request.php

@@ -464,7 +464,11 @@ class Request
             $this->parseUploadFiles($http_post_boundary);
             return;
         }
-        \parse_str($body_buffer, $this->_data['post']);
+        if (\preg_match('/\bjson\b/i', $content_type)) {
+            $this->_data['post'] = (array) json_decode($body_buffer, true);
+        } else {
+            \parse_str($body_buffer, $this->_data['post']);
+        }
         if ($cacheable) {
             static::$_postCache[$body_buffer] = $this->_data['post'];
             if (\count(static::$_postCache) > 256) {