change to support http case

This commit is contained in:
William Bell committed 2023-07-17 22:33:38 +01:00
1 parent b3cb49ecb7
commit baf7544c04
2 files changed
+4 -9

No files matched your search

+2 -2
View File
@@ -12,7 +12,7 @@ let __multipart(req, res) = do
for (j from 0 to headerLines.length) do
let header = headerLines[j].splitN(": ", 2)
if (header.length != 2) continue
headers[header[0]] = header[1]
headers[header[0].lower()] = header[1]
if (lines.length != 2) continue
let body = lines[1]
if (i != parts.length-1) do
@@ -41,6 +41,6 @@ let formdata(req, res) = do
req.files = {}
if (req.method != "POST") return res.next()
if ("content-type" in req.headers && req.headers["content-type"].startswith("multipart/form-data")) do
if ("content-type" in req.headers && req.headers["content-type"].lower().startswith("multipart/form-data")) do
return __multipart(req, res)
res.next()
+2 -7
View File
@@ -1,10 +1,9 @@
import "caseInsensitive" as *
let readChunkSize = 1024^2
let methodsWithBody = ["POST", "PUT", "PATCH"]
let caseInsensitive = ['accept', 'accept-encoding', 'accept-language', 'cache-control', 'connection', 'content-encoding', 'content-language', 'content-length', 'content-location', 'content-type', 'date', 'host', 'if-match', 'if-none-match', 'if-range', 'if-unmodified-since', 'last-modified', 'location', 'referer', 'user-agent']
let parse(conn) = do
let headerData = conn.readUntil(buffer().from("\r\n\r\n"))
let inBody = false
@@ -17,12 +16,8 @@ let parse(conn) = do
for (i from 1 to split.length) do
let header = split[i].splitN(": ", 2)
if (header.length < 2) break
let name = header[0]
let name = header[0].lower()
let value = header[1]
let lowered = name.lower()
if (lowered in caseInsensitive) do
name = lowered
value = value.lower()
headers[name] = value
let body = buffer()