diff options
author | bptato <nincsnevem662@gmail.com> | 2024-08-03 01:14:41 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-08-03 01:54:35 +0200 |
commit | 4c64687290c908cd791a058dede9bd4f2a1c7757 (patch) | |
tree | 4e72720aa016320a02d19b4a051b9b9916b714f9 /adapter/protocol | |
parent | 270cf870eb84e80f2de1f2be64b682849ca55585 (diff) | |
download | chawan-4c64687290c908cd791a058dede9bd4f2a1c7757.tar.gz |
loader: move back data URL handling
data URIs can get megabytes long; however, you can only stuff so many bytes into the envp. (This was thwarting my efforts to view pandoc- generated standalone HTML in Chawan.) So put `data:' back into the loader process.
Diffstat (limited to 'adapter/protocol')
-rw-r--r-- | adapter/protocol/data.nim | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/adapter/protocol/data.nim b/adapter/protocol/data.nim deleted file mode 100644 index 72263780..00000000 --- a/adapter/protocol/data.nim +++ /dev/null @@ -1,32 +0,0 @@ -when NimMajor >= 2: - import std/envvars -else: - import std/os -import std/strutils - -import loader/connecterror -import types/opt -import utils/twtstr - -proc main() = - let str = getEnv("MAPPED_URI_PATH") - const iu = $int(ERROR_INVALID_URL) - var ct = str.until(',') - if AllChars - Ascii + Controls - {'\t', ' '} in ct: - stdout.write("Cha-Control: ConnectionError " & iu & " invalid data URL") - return - let sd = ct.len + 1 # data start - let body = percentDecode(str, sd) - if ct.endsWith(";base64"): - let d = atob0(body) # decode from ct end + 1 - if d.isSome: - ct.setLen(ct.len - ";base64".len) # remove base64 indicator - stdout.write("Content-Type: " & ct & "\n\n") - stdout.write(d.get) - else: - stdout.write("Cha-Control: ConnectionError " & iu & " invalid data URL") - else: - stdout.write("Content-Type: " & ct & "\n\n") - stdout.write(body) - -main() |