|
|
@ -12,26 +12,32 @@ class ListenerHandler(BaseHTTPRequestHandler): |
|
|
|
def do_POST(self): |
|
|
|
try: |
|
|
|
content_length = int(self.headers.get("Content-Length")) |
|
|
|
all_logs = self.rfile.read(content_length).split('\n') |
|
|
|
all_logs = self.rfile.read(content_length).decode("utf-8").split('\n') |
|
|
|
if len(all_logs) == 0: |
|
|
|
self.send_response(400, "Bad Request") |
|
|
|
self._set_response(400, "Bad Request", b"Bad request you got there, pal") |
|
|
|
return |
|
|
|
|
|
|
|
for log in all_logs: |
|
|
|
if log != "": |
|
|
|
if persistent_flags.get_server_error(): |
|
|
|
self.send_response(500, "Issue!!!!!!!") |
|
|
|
self._set_response(500, "Issue!!!!!!!", b"Not good, not good at all.") |
|
|
|
return |
|
|
|
|
|
|
|
logs_list.list.append(log) |
|
|
|
|
|
|
|
self.send_response(200, "Ok") |
|
|
|
self._set_response(200, "OK", b"Shabam! got logs.") |
|
|
|
return |
|
|
|
|
|
|
|
except IndexError: |
|
|
|
self.send_response(400, "Bad Request") |
|
|
|
self._set_response(400, "Bad Request", b"Bad request you got there, pal") |
|
|
|
return |
|
|
|
|
|
|
|
def _set_response(self, http_code, http_description, byte_body): |
|
|
|
self.send_response(http_code, http_description) |
|
|
|
self.send_header('Content-type', 'text/html') |
|
|
|
self.end_headers() |
|
|
|
self.wfile.write(byte_body) |
|
|
|
|
|
|
|
|
|
|
|
class MockLogzioListener: |
|
|
|
def __init__(self): |
|
|
|