gemini.git

going-flying.com gemini git repository

summary

tree

log

refs

e23596ff0eb1a4b26eb28bcaa261b833c33e7abb - Matthew Ernisse - 1598915032

handle 404 and fully qualify HTTPError

view tree

view raw

diff --git a/cgi-bin/rfc b/cgi-bin/rfc
index 47d989e..2c3e87a 100755
--- a/cgi-bin/rfc
+++ b/cgi-bin/rfc
@@ -23,7 +23,7 @@ def check_requested_path():
 def get_rfc(rfc):
 	''' Return the text contents of an RFC. '''
 	resp = requests.get(
-		f'https://tools.ietf.org/rfc/{rfc}.txt',
+		f'https://tools.ietf.org/rfc/{rfc}',
 		headers={
 			'User-Agent': 'gemini-rfc-proxy/matt@going-flying.com'
 		}
@@ -41,8 +41,12 @@ if __name__ == "__main__":
 		print(f'59 {str(e)}')
 		sys.exit()
 
-	except HTTPError as e:
-		if e.errno > 399 and e.errno < 500:
+	except requests.exceptions.HTTPError as e:
+		if e.errno == 404:
+			print(f'51 Not Found.')
+			sys.exit()
+
+		elif e.errno > 399 and e.errno < 500:
 			print(f'43 {e.strerror}')
 			sys.exit()
 		else: