~earboxer/browset

419aafcf112fdb558f2a36fc4d92cd2b7ad2b936 — Zach DeCook 1 year, 10 months ago 7682658
protocols: Show errors instead of hanging or hiding them
2 files changed, 6 insertions(+), 3 deletions(-)

M protocol/gemini.py
M protocol/http.py
M protocol/gemini.py => protocol/gemini.py +2 -2
@@ 25,8 25,8 @@ class GeminiProtocol():
            s = context.wrap_socket(s, server_hostname = hostname)
            s.sendall((url + '\r\n').encode("UTF-8"))
            fp = s.makefile("rb")
        except:
            return ("text/error",["error"])
        except Exception as e:
            return ("text/error",["error\n", str(e)])
        header = fp.readline()
        header = header.decode("UTF-8").strip()
        if header[0:1] == "2":

M protocol/http.py => protocol/http.py +4 -1
@@ 1,5 1,8 @@
import requests
class HttpProtocol():
    def get(url):
        r = requests.get(url)
        try:
          r = requests.get(url, timeout=5)
        except Exception as e:
          return ("text/error", ["error\n", str(e)])
        return (r.headers['content-type'].split(';')[0], r)