From 72cfcfbdd1e8b8c8370b07b0d6f14070b928459c Mon Sep 17 00:00:00 2001 From: swee Date: Mon, 13 Jan 2025 21:57:21 -0800 Subject: [PATCH] Update server.py --- server.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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