about summary refs log tree commit diff stats
path: root/src/local
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-16 20:11:53 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-16 20:17:01 +0100
commit9aa8e20bd5552916c6b382659224f1003b02dbc7 (patch)
tree95c39447d43e14a8435a25f83ecd76a012a94678 /src/local
parent5b330ef56e50ad454712a77f805377b41dfb140b (diff)
downloadchawan-9aa8e20bd5552916c6b382659224f1003b02dbc7.tar.gz
container: fall back to text/plain instead of application/octet-stream
This has its own problems, but application/octet-stream has the horrible
consequence that opening any local file with an unrecognized type
automatically quits the browser.

(FWIW, w3m also falls back to text/plain, so it's not such an unreasonable
default.)

The proper solution would be to a) fix the bug that makes the browser
auto-quit and b) show a "what to do" prompt for unrecognized file types
(and allow users to override it, preferably on a per-protocol basis.)
Diffstat (limited to 'src/local')
-rw-r--r--src/local/container.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index 011c7279..62799c56 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -1412,7 +1412,8 @@ proc applyResponse*(container: Container; response: Response;
   if container.contentType.isNone:
     var contentType = response.getContentType()
     if contentType == "application/octet-stream":
-      contentType = mimeTypes.guessContentType(container.url.pathname)
+      contentType = mimeTypes.guessContentType(container.url.pathname,
+        "text/plain")
     container.contentType = some(contentType)
   # setup charsets:
   # * override charset