ソースを参照

rewind body before read

Maurits van der Schee 4年前
コミット
7903b64c3a
2個のファイルの変更14行の追加5行の削除
  1. 7
    3
      api.php
  2. 7
    2
      src/Tqdev/PhpCrudApi/Api.php

+ 7
- 3
api.php ファイルの表示

@@ -4435,7 +4435,6 @@ namespace Tqdev\PhpCrudApi\Controller {
4435 4435
     {
4436 4436
         private $service;
4437 4437
         private $responder;
4438
-        private $geoJsonConverter;
4439 4438
 
4440 4439
         public function __construct(Router $router, Responder $responder, GeoJsonService $service)
4441 4440
         {
@@ -10134,9 +10133,14 @@ namespace Tqdev\PhpCrudApi {
10134 10133
                 $request = $this->applySlim3Hack($request);
10135 10134
             } else {
10136 10135
                 $body = $request->getBody();
10137
-                if ($body->isReadable() && $body->isSeekable()) {
10136
+                if ($body->isReadable()) {
10137
+                    if ($body->isSeekable()) {
10138
+                        $body->rewind();
10139
+                    }
10138 10140
                     $contents = $body->getContents();
10139
-                    $body->rewind();
10141
+                    if ($body->isSeekable()) {
10142
+                        $body->rewind();
10143
+                    }
10140 10144
                     if ($contents) {
10141 10145
                         $parsedBody = $this->parseBody($contents);
10142 10146
                         $request = $request->withParsedBody($parsedBody);

+ 7
- 2
src/Tqdev/PhpCrudApi/Api.php ファイルの表示

@@ -171,9 +171,14 @@ class Api implements RequestHandlerInterface
171 171
             $request = $this->applySlim3Hack($request);
172 172
         } else {
173 173
             $body = $request->getBody();
174
-            if ($body->isReadable() && $body->isSeekable()) {
174
+            if ($body->isReadable()) {
175
+                if ($body->isSeekable()) {
176
+                    $body->rewind();
177
+                }
175 178
                 $contents = $body->getContents();
176
-                $body->rewind();
179
+                if ($body->isSeekable()) {
180
+                    $body->rewind();
181
+                }
177 182
                 if ($contents) {
178 183
                     $parsedBody = $this->parseBody($contents);
179 184
                     $request = $request->withParsedBody($parsedBody);

読み込み中…
キャンセル
保存