about summary refs log tree commit diff stats
path: root/src/loader
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-08-15 19:11:49 +0200
committerbptato <nincsnevem662@gmail.com>2024-08-15 19:23:55 +0200
commit4bf895db711f3d4d229d3f18fbb2145cce2a73af (patch)
tree2e81c7399de03aebb9dfa166eba6ee809a75cd2e /src/loader
parent885a3493b6cad4b4247a200928fe61e41883aaba (diff)
downloadchawan-4bf895db711f3d4d229d3f18fbb2145cce2a73af.tar.gz
xhr: more progress
* add responseText, response
* add net tests
	-> currently sync XHR only; should find a way to do async
	   tests...
* update monoucha
	-> simplified & updated some related code that no longer worked
	   properly
Diffstat (limited to 'src/loader')
-rw-r--r--src/loader/loader.nim2
-rw-r--r--src/loader/response.nim13
2 files changed, 8 insertions, 7 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim
index dfc95b8b..c9025153 100644
--- a/src/loader/loader.nim
+++ b/src/loader/loader.nim
@@ -1167,6 +1167,8 @@ proc doRequest*(loader: FileLoader; request: Request): Response =
     r.sread(response.headers) # packet 3
     # Only a stream of the response body may arrive after this point.
     response.body = stream
+    response.resumeFun = proc(outputId: int) =
+      loader.resume(outputId)
   else:
     var msg: string
     r.sread(msg) # packet 1
diff --git a/src/loader/response.nim b/src/loader/response.nim
index 8143ccbf..6463080a 100644
--- a/src/loader/response.nim
+++ b/src/loader/response.nim
@@ -89,13 +89,12 @@ proc close*(response: Response) {.jsfunc.} =
     response.body = nil
 
 func getCharset*(this: Response; fallback: Charset): Charset =
-  if "Content-Type" notin this.headers.table:
-    return fallback
-  let header = this.headers.table["Content-Type"][0].toLowerAscii()
-  let cs = header.getContentTypeAttr("charset").getCharset()
-  if cs == CHARSET_UNKNOWN:
-    return fallback
-  return cs
+  this.headers.table.withValue("Content-Type", p):
+    let header = p[][0].toLowerAscii()
+    let cs = header.getContentTypeAttr("charset").getCharset()
+    if cs != CHARSET_UNKNOWN:
+      return cs
+  return fallback
 
 func getContentType*(this: Response; fallback = "application/octet-stream"):
     string =