File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
src/WebServCo/JSONAPI/Service Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,15 @@ public function handleRequest(ServerRequestInterface $request): bool
89
89
*/
90
90
private function handleFormProcessing (array $ requestBodyAsArray ): bool
91
91
{
92
+ if ($ requestBodyAsArray === []) {
93
+ /**
94
+ * Request body is an empty array if request should not have a body.
95
+ *
96
+ * @see JSONAPIRequestService.getRequestBodyAsArray
97
+ */
98
+ return true ;
99
+ }
100
+
92
101
/**
93
102
* Start from local fields and iterate,
94
103
* because id is stored in the actual formField (string key),
@@ -120,6 +129,15 @@ private function handleFormProcessing(array $requestBodyAsArray): bool
120
129
*/
121
130
private function handleVersionMatchCheck (array $ requestBodyAsArray ): bool
122
131
{
132
+ if ($ requestBodyAsArray === []) {
133
+ /**
134
+ * Request body is an empty array if request should not have a body.
135
+ *
136
+ * @see JSONAPIRequestService.getRequestBodyAsArray
137
+ */
138
+ return true ;
139
+ }
140
+
123
141
try {
124
142
if (!$ this ->requestService ->versionMatches ($ requestBodyAsArray , 1.1 )) {
125
143
$ this ->addErrorMessage ('JSONAPI version does not match. ' );
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ public function getRequestBodyAsArray(ServerRequestInterface $request): array
34
34
$ requestBody = $ request ->getBody ()->getContents ();
35
35
36
36
if ($ requestBody === '' ) {
37
+ if (!$ this ->requestBodyService ->canHaveRequestBody ($ request )) {
38
+ // Correct that there is no request body.
39
+ return [];
40
+ }
41
+
37
42
// Possible situation: the body contents were read elsewhere and the stream was not rewinded.
38
43
throw new UnexpectedValueException ('Request body is empty. ' );
39
44
}
You can’t perform that action at this time.
0 commit comments