Skip to content

Commit cdb317b

Browse files
committed
make optional post data as well, remove unnecessary check
1 parent 24eb557 commit cdb317b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

resources/lib/UnityHTTPD.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,24 +230,15 @@ public static function errorHandler(int $severity, string $message, string $file
230230

231231
public static function getPostData(string $key): string
232232
{
233-
if (!array_key_exists("REQUEST_METHOD", $_SERVER)) {
234-
throw new RuntimeException('$_SERVER has no array key "REQUEST_METHOD"');
235-
}
236-
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
237-
self::badRequest('$_SERVER["REQUEST_METHOD"] != "POST"');
238-
}
239233
if (!array_key_exists($key, $_POST)) {
240234
self::badRequest("\$_POST has no array key '$key'");
241235
}
242236
return $_POST[$key];
243237
}
244238

245-
public static function getOptionalQueryParameter(string $key): ?string
239+
public static function getOptionalPostData(string $key): ?string
246240
{
247-
if (!array_key_exists($key, $_GET)) {
248-
return null;
249-
}
250-
return $_GET[$key];
241+
return @$_POST[$key];
251242
}
252243

253244
public static function getQueryParameter(string $key): string
@@ -258,6 +249,11 @@ public static function getQueryParameter(string $key): string
258249
return $_GET[$key];
259250
}
260251

252+
public static function getOptionalQueryParameter(string $key): ?string
253+
{
254+
return @$_GET[$key];
255+
}
256+
261257
public static function getUploadedFileContents(
262258
string $filename,
263259
bool $do_delete_tmpfile_after_read = true,

0 commit comments

Comments
 (0)