diff --git a/server.py b/server.py index 31b5b31..2f08ffe 100644 --- a/server.py +++ b/server.py @@ -36,6 +36,7 @@ def relay(): gemraw = bytearray() num = 0 ok = False + binary = False while True: gemresponse = gemsocket.recv(2048) try: @@ -51,15 +52,18 @@ def relay(): elif num >= 2 and ok and not mimetype in ["text/gemini", ""]: for i in gemresponse: gemraw.append(i) - if ok and mimetype in ["text/gemini", ""] and gemresponse.decode() != "": - received += gemresponse.decode() - else: - break + try: + if gemresponse.decode() != "": + received += gemresponse.decode() + else: + break + except: + binary = True num+=1 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 ok and not mimetype.lower() in ["text/gemini", ""]: + if binary: return bytes(gemraw) received = received.replace("\r", "") firstline = True