Spaces:
Running
Running
Upload ApiValidator.php
#1
by
kingkay000 - opened
easypay-v21/includes/ApiValidator.php
CHANGED
|
@@ -35,14 +35,16 @@ class ApiValidator
|
|
| 35 |
];
|
| 36 |
}
|
| 37 |
|
| 38 |
-
// Check Content-Type header
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
// Validate API key if configured
|
|
|
|
| 35 |
];
|
| 36 |
}
|
| 37 |
|
| 38 |
+
// Check Content-Type header (only for methods with body)
|
| 39 |
+
if (in_array($method, ['POST', 'PUT', 'PATCH'])) {
|
| 40 |
+
$contentType = $_SERVER['CONTENT_TYPE'] ?? '';
|
| 41 |
+
if (stripos($contentType, 'application/json') === false) {
|
| 42 |
+
return [
|
| 43 |
+
'valid' => false,
|
| 44 |
+
'error' => 'Invalid Content-Type. Expected application/json',
|
| 45 |
+
'http_code' => 400
|
| 46 |
+
];
|
| 47 |
+
}
|
| 48 |
}
|
| 49 |
|
| 50 |
// Validate API key if configured
|