olliNiinivaara / GuildenStern

Modular multithreading HTTP/1.1 + WebSocket server framework
MIT License
80 stars 7 forks source link

missing headers with multipartserver POST #25

Closed ITwrx closed 4 months ago

ITwrx commented 4 months ago

hi, I'm trying to get the sessionId from a browser cookie, but headers seem to be missing when POSTing via the multipartserver. The header values are retrievable using http.headers with GET and POST with the httpserver.

With multipartserver:

echo http.headers.getOrDefault("cookie") is empty

echo http.headers outputs:

{: , content-length: , content-type: , content-disposition: form-data; name="alt_txt", referer: , cookie: }

alt_txt is the last input in the form, not that that is relevant.

the servers are initialized thusly:

let getserver = newHttpServer(handleGet, contenttype = NoBody, headerfields = ["cookie"])
getserver.start(5060)
let postserver = newHttpServer(handlePost, loglevel = INFO, headerfields = ["referer", "cookie"])
postserver.start(5061, threadpoolsize = 200, maxactivethreadcount = 20)
let uploadserver = newMultipartServer(handleMultipartPost, loglevel = INFO, headerFields = ["referer", "cookie"])
uploadserver.start(5062, threadpoolsize = 200, maxactivethreadcount = 20)
joinThreads(getserver.thread, postserver.thread, uploadserver.thread)

The multipartserver docs page says:

For accessing other fields, use http.headers

but maybe i'm doing it wrong?

P.S. I added content-length to both POST servers initialization and it exhibited the same behavior. i.e it is available with httpserver POST, but not multipartserver POST.

Thanks

ITwrx commented 4 months ago

well, i just tried this with the mutiparttest.nim (forgot to try that first) and the headers were available, so i must be doing something wrong.