From 27c2285c59d72c01b69d4e57e5cfc78130f2370d Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Mon, 9 Jan 2012 14:34:38 +0100 Subject: `server` function: Serve everything as UTF-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even though this is not technically correct for binary files, it doesn’t actually break anything. --- .functions | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to '.functions') diff --git a/.functions b/.functions index 0ae79c9..5b7b8e3 100644 --- a/.functions +++ b/.functions @@ -8,7 +8,8 @@ function server() { local port="${1:-8000}" open "http://localhost:${port}/" # Set the default Content-Type to `text/plain` instead of `application/octet-stream` - python -c "import SimpleHTTPServer; import sys; sys.argv = [None, '$port']; SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map[''] = 'text/plain;charset=UTF-8'; SimpleHTTPServer.test();" + # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) + python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port" } # Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL. -- cgit v1.2.3