about summary refs log tree commit diff
path: root/zachwalk.py
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-02-19 10:36:37 -0500
committerZach DeCook <zachdecook@librem.one>2021-02-19 10:36:37 -0500
commit495e6f423b596a217ec8db9c6d010070611dfbf8 (patch)
tree7b3ed88df9a05a112db892456ea936bc8a866dc2 /zachwalk.py
parent0589ac0ce6fb56b1fe6af58e26297d8a19e908de (diff)
downloadzachwalk-495e6f423b596a217ec8db9c6d010070611dfbf8.tar.gz
gemini request: wrap more in try block
Diffstat (limited to 'zachwalk.py')
-rwxr-xr-xzachwalk.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/zachwalk.py b/zachwalk.py
index 0e5feb6..6da89c4 100755
--- a/zachwalk.py
+++ b/zachwalk.py
@@ -15,14 +15,14 @@ def getnewestdate(url):
     hostname = url.split('/')[2]
     try:
      s = socket.create_connection((hostname, 1965),timeout=2)
+     context = ssl.SSLContext()
+     context.check_hostname = False
+     context.verify_mode = ssl.CERT_NONE
+     s = context.wrap_socket(s, server_hostname = hostname)
+     s.sendall((url + '\r\n').encode("UTF-8"))
+     fp = s.makefile("rb")
     except:
      return DEFAULT
-    context = ssl.SSLContext()
-    context.check_hostname = False
-    context.verify_mode = ssl.CERT_NONE
-    s = context.wrap_socket(s, server_hostname = hostname)
-    s.sendall((url + '\r\n').encode("UTF-8"))
-    fp = s.makefile("rb")
     header = fp.readline()
     header = header.decode("UTF-8").strip()
     # TODO: something special if status is not 2x