diff --git a/document.py b/document.py index 417e4e5..968e37f 100644 --- a/document.py +++ b/document.py @@ -45,14 +45,9 @@ def request (self, url): #Sends a HTTP request (useful for HTTP APIS). If you do return(f.read().decode('utf-8')) def send (self): #Send the answer to the browser - self.connection.send_header(self.header[0], self.header[1]) self.connection.send_response(self.response) + self.connection.send_header(self.header[0], self.header[1]) self.connection.end_headers() - try: - self.connection.flush_headers() - print ("Headers flushed!") - except: - print ("Headers can't be flushed") if (self.response != 302): self.document = self.document.replace ('', '') #Remove reference mark before sending diff --git a/server.py b/server.py index 9b01ff9..fd9b009 100644 --- a/server.py +++ b/server.py @@ -52,14 +52,9 @@ def do_GET(self): #Decide wether a search or the style.css was requested if (path == "/style.css"): self.document = open('style.css', 'r').read() - self.send_header('Content-type', 'text/html') self.send_response(200) + self.send_header('Content-type', 'text/html') self.end_headers() - try: - self.flush_headers() - print ("Headers flushed!") - except: - print ("Headers can't be flushed") self.wfile.write(bytes(self.document, "utf-8")) elif (path == "/proxy.pac"): self.document = open('proxy.pac', 'r').read() @@ -67,14 +62,9 @@ def do_GET(self): self.document = self.document.replace('', google_domain, 1) self.document = self.document.replace('', squid_hostname, 1) self.document = self.document.replace('', str(squid_port), 1) - self.send_header('Content-type', 'x-ns-proxy-autoconfig') self.send_response(200) + self.send_header('Content-type', 'x-ns-proxy-autoconfig') self.end_headers() - try: - self.flush_headers() - print ("Headers flushed!") - except: - print ("Headers can't be flushed") self.wfile.write(bytes(self.document, "utf-8")) elif (arguments["q"] != None): arguments["q"] = arguments["q"].replace(keyword + '+', '', 1) @@ -82,14 +72,9 @@ def do_GET(self): command = commands(self) search(command).search(arguments["q"]) else: - self.send_header('Content-type', 'text/html') self.send_response(404) + self.send_header('Content-type', 'text/html') self.end_headers() - try: - self.flush_headers() - print ("Headers flushed!") - except: - print ("Headers can't be flushed") self.wfile.write(bytes('Not found. Please visit https://github.com/HcDevel/Siri-API/wiki/_pages', "utf-8")) return