summary refs log tree commit diff
path: root/protocol
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2023-01-20 08:10:56 -0500
committerZach DeCook <zachdecook@librem.one>2023-01-20 08:10:56 -0500
commit419aafcf112fdb558f2a36fc4d92cd2b7ad2b936 (patch)
tree5e6d21267aadb5470b311bfba4f71a59ca4f54bc /protocol
parent7682658a6d9a0e167fe22debcbee77522b42be92 (diff)
downloadbrowset-419aafcf112fdb558f2a36fc4d92cd2b7ad2b936.tar.gz
protocols: Show errors instead of hanging or hiding them
Diffstat (limited to 'protocol')
-rw-r--r--protocol/gemini.py4
-rw-r--r--protocol/http.py5
2 files changed, 6 insertions, 3 deletions
diff --git a/protocol/gemini.py b/protocol/gemini.py
index b4cccbe..05f86ce 100644
--- a/protocol/gemini.py
+++ b/protocol/gemini.py
@@ -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":
diff --git a/protocol/http.py b/protocol/http.py
index 2f9672c..96428f9 100644
--- a/protocol/http.py
+++ b/protocol/http.py
@@ -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)