about summary refs log tree commit diff stats
path: root/src/html/xmlhttprequest.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-03-12 18:32:57 +0100
committerbptato <nincsnevem662@gmail.com>2025-03-12 18:32:57 +0100
commit50a747ae1b6ee7275c93984f4f99d6abca91c82c (patch)
treeb13355f48a2df9891fa8718709f7f8e3b110460d /src/html/xmlhttprequest.nim
parent84b12b22dfc218f7f353ab51d1a3235ce6d8596b (diff)
downloadchawan-50a747ae1b6ee7275c93984f4f99d6abca91c82c.tar.gz
headers: hide table, always specify guard
Diffstat (limited to 'src/html/xmlhttprequest.nim')
-rw-r--r--src/html/xmlhttprequest.nim9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/html/xmlhttprequest.nim b/src/html/xmlhttprequest.nim
index 556d32b1..c24fa262 100644
--- a/src/html/xmlhttprequest.nim
+++ b/src/html/xmlhttprequest.nim
@@ -1,6 +1,5 @@
 import std/options
 import std/strutils
-import std/tables
 
 import chagashi/charset
 import chagashi/decoder
@@ -83,7 +82,7 @@ func newXMLHttpRequest(): XMLHttpRequest {.jsctor.} =
   let upload = XMLHttpRequestUpload()
   return XMLHttpRequest(
     upload: upload,
-    headers: newHeaders(),
+    headers: newHeaders(hgRequest),
     responseObject: JS_UNDEFINED
   )
 
@@ -149,7 +148,7 @@ proc open(ctx: JSContext; this: XMLHttpRequest; httpMethod, url: string;
   else:
     this.flags.incl(xhrfSync)
   this.requestMethod = httpMethod
-  this.headers = newHeaders()
+  this.headers = newHeaders(hgRequest)
   this.response = makeNetworkError()
   this.received = ""
   this.requestURL = parsedURL
@@ -178,7 +177,7 @@ proc setRequestHeader(this: XMLHttpRequest; name, value: string):
     return errDOMException("Invalid header name or value", "SyntaxError")
   if isForbiddenRequestHeader(name, value):
     return ok()
-  this.headers.table[name.toHeaderCase()] = @[value]
+  this.headers[name] = value
   ok()
 
 proc `withCredentials=`(this: XMLHttpRequest; withCredentials: bool):
@@ -383,7 +382,7 @@ proc getResponseHeader(ctx: JSContext; this: XMLHttpRequest; name: string):
 proc getAllResponseHeaders(this: XMLHttpRequest): string {.jsfunc.} =
   result = ""
   #TODO sort, should use the filtered header list, etc.
-  for k, v in this.response.headers.table:
+  for k, v in this.response.headers:
     if k.isForbiddenResponseHeaderName():
       continue
     for it in v: