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
Wed, Nov 6, 13:34 (22 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2231698
Default Alt Text
D2691.id6815.diff (1 KB)

Event Timeline