Page MenuHomeDevCentral

D2691.id6815.diff
No OneTemporary

D2691.id6815.diff

diff --git a/src/BaseService.php b/src/BaseService.php
--- a/src/BaseService.php
+++ b/src/BaseService.php
@@ -27,9 +27,19 @@
echo $responseBody;
}
+ protected function sendBadRequestResponse () {
+ header("HTTP/1.0 400 Bad Request");
+ http_response_code(400);
+ }
+
protected function sendInvalidMethodResponse () {
header("HTTP/1.0 405 Method Not Allowed");
http_response_code(405);
}
+ protected function sendInternalServerErrorResponse () {
+ header("HTTP/1.0 500 Internal Server Error");
+ http_response_code(500);
+ }
+
}
diff --git a/src/Service.php b/src/Service.php
--- a/src/Service.php
+++ b/src/Service.php
@@ -37,8 +37,19 @@
}
public function put ($data) : void {
+ if ($data === NULL) {
+ $this->sendBadRequestResponse();
+ return;
+ }
+
+ $log = self::getServersLogFile();
+ if (!$log) {
+ $this->sendInternalServerError();
+ return;
+ }
+
Log::addEntryToJSONFile(
- self::getServersLogFile(),
+ $log,
LogEntry::fromJSON($data)
);

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 08:36 (18 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2268605
Default Alt Text
D2691.id6815.diff (1 KB)

Event Timeline