|
@ -12,26 +12,32 @@ class ListenerHandler(BaseHTTPRequestHandler): |
|
|
def do_POST(self): |
|
|
def do_POST(self): |
|
|
try: |
|
|
try: |
|
|
content_length = int(self.headers.get("Content-Length")) |
|
|
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: |
|
|
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 |
|
|
return |
|
|
|
|
|
|
|
|
for log in all_logs: |
|
|
for log in all_logs: |
|
|
if log != "": |
|
|
if log != "": |
|
|
if persistent_flags.get_server_error(): |
|
|
if persistent_flags.get_server_error(): |
|
|
self.send_response(500, "Issue!!!!!!!") |
|
|
|
|
|
|
|
|
self._set_response(500, "Issue!!!!!!!", b"Not good, not good at all.") |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
logs_list.list.append(log) |
|
|
logs_list.list.append(log) |
|
|
|
|
|
|
|
|
self.send_response(200, "Ok") |
|
|
|
|
|
|
|
|
self._set_response(200, "OK", b"Shabam! got logs.") |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
except IndexError: |
|
|
except IndexError: |
|
|
self.send_response(400, "Bad Request") |
|
|
|
|
|
|
|
|
self._set_response(400, "Bad Request", b"Bad request you got there, pal") |
|
|
return |
|
|
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: |
|
|
class MockLogzioListener: |
|
|
def __init__(self): |
|
|
def __init__(self): |
|
|