Transition to new status system.
This commit is contained in:
parent
0bea25fed5
commit
ce2cf8c5c4
15
av98.py
15
av98.py
|
@ -264,8 +264,8 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
|
||||||
# Look at what we got
|
# Look at what we got
|
||||||
status, mime = header.split("\t")
|
status, mime = header.split("\t")
|
||||||
# Handle different statuses.
|
# Handle different statuses.
|
||||||
# Everything other than 200 should return here
|
# Everything other than success
|
||||||
if status in ("2", "200"):
|
if status.startswith("2"):
|
||||||
if mime == "":
|
if mime == "":
|
||||||
mime = "text/gemini; charset=utf-8"
|
mime = "text/gemini; charset=utf-8"
|
||||||
mime, mime_options = cgi.parse_header(mime)
|
mime, mime_options = cgi.parse_header(mime)
|
||||||
|
@ -276,18 +276,17 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
|
||||||
print("Header declared unknown encoding %s" % value)
|
print("Header declared unknown encoding %s" % value)
|
||||||
return
|
return
|
||||||
# Handle redirects
|
# Handle redirects
|
||||||
# (Temporarily accepting unofficial conman status codes)
|
elif status.startswith("3"):
|
||||||
elif status in ("3", "301"):
|
|
||||||
self._debug("Following redirect to %s." % mime)
|
self._debug("Following redirect to %s." % mime)
|
||||||
new_gi = GeminiItem(gi.host, gi.port, mime, None)
|
new_gi = GeminiItem(gi.host, gi.port, mime, None)
|
||||||
self._go_to_gi(new_gi)
|
self._go_to_gi(new_gi)
|
||||||
return
|
return
|
||||||
# Not found
|
# Not found
|
||||||
elif status in ("4", "404"):
|
elif status.startswith("4") or status.startswith("5"):
|
||||||
print("Path %s does not exist at %s:%d" % (gi.path, gi.host, gi.port))
|
print("Error: %s" % mime)
|
||||||
return
|
return
|
||||||
|
|
||||||
# If we're still here, this is a 200
|
# If we're still here, this is a success and there's a response body
|
||||||
|
|
||||||
# Save the result in a temporary file
|
# Save the result in a temporary file
|
||||||
## Delete old file
|
## Delete old file
|
||||||
|
@ -863,7 +862,7 @@ Bookmarks are stored in the ~/.av98-bookmarks.txt file."""
|
||||||
print("You need to 'add' some bookmarks, first")
|
print("You need to 'add' some bookmarks, first")
|
||||||
else:
|
else:
|
||||||
gi = GeminiItem(None, None, os.path.expanduser(file_name),
|
gi = GeminiItem(None, None, os.path.expanduser(file_name),
|
||||||
"1", file_name)
|
file_name)
|
||||||
self._go_to_gi(gi)
|
self._go_to_gi(gi)
|
||||||
|
|
||||||
### Help
|
### Help
|
||||||
|
|
Loading…
Reference in New Issue