diff --git a/server.py b/server.py index 9afc884..69d4e3b 100644 --- a/server.py +++ b/server.py @@ -35,6 +35,7 @@ def relay(): mimetype = "" gemraw = bytearray() num = 0 + ok = False while True: gemresponse = gemsocket.recv(2048) try: @@ -42,13 +43,12 @@ def relay(): try: mimetype = gemresponse.decode().replace("\r","").split("\n")[0].split(" ")[1].split(";")[0] ok = gemresponse.decode().replace("\r","").split("\n")[0].split(" ")[0][0] == "2" - if mimetype != "text/gemini".lower() and ok: - print("Non-ordinary type! " + mimetype) + print("Non-ordinary type! " + mimetype) except: pass - elif num == 1 and not mimetype in ["text/gemini", ""]: + elif num == 1 and ok and not mimetype in ["text/gemini", ""]: pass - elif num >= 2 and not mimetype in ["text/gemini", ""]: + elif num >= 2 and ok and not mimetype in ["text/gemini", ""]: for i in gemresponse: gemraw.append(i) if mimetype in ["text/gemini", ""] and gemresponse.decode() != "": @@ -59,7 +59,7 @@ def relay(): except: return f'\nSomething went wrong...

Something went wrong...

The file that the Gemini server sent couldn\'t be decoded by Gem2Browser.

' print(mimetype) - if not mimetype.lower() in ["text/gemini", ""]: + if ok and not mimetype.lower() in ["text/gemini", ""]: return bytes(gemraw) received = received.replace("\r", "") firstline = True