Skip to content

Commit be03546

Browse files
committed
Return a 422 when a parameter is missing
1 parent f67872b commit be03546

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Resumable.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,20 @@ private function createSafeName(string $name): string
171171
* - If the request returns anything else, the chunk will be uploaded in the standard fashion.
172172
* (It is recommended to return 204 No Content in these cases if possible
173173
* to avoid unwarranted notices in browser consoles.)
174+
* - If this request returns a 422 HTTP code, one of the parameters is missing
174175
*/
175176
public function handleTestChunk(): ResponseInterface
176177
{
177178
$identifier = $this->resumableParam($this->resumableOption['identifier']);
178179
$filename = $this->resumableParam($this->resumableOption['filename']);
179-
$chunkNumber = (int) $this->resumableParam($this->resumableOption['chunkNumber']);
180+
$chunkNumber = $this->resumableParam($this->resumableOption['chunkNumber']);
181+
182+
// A parameter is missing
183+
if ($identifier === null || $filename === null || $chunkNumber === null) {
184+
return $this->response->withStatus(422);
185+
}
180186

181-
if ($this->isChunkUploaded($identifier, $filename, $chunkNumber)) {
187+
if ($this->isChunkUploaded($identifier, $filename, (int) $chunkNumber)) {
182188
// We have the chunk, do not send it
183189
return $this->response->withStatus(200);
184190
}

0 commit comments

Comments
 (0)