OxygenFramework / Oxygen.jl

💨 A breath of fresh air for programming web apps in Julia
https://oxygenframework.github.io/Oxygen.jl/
MIT License
383 stars 25 forks source link

duplicate headers when serving dynamic/static files #152

Closed tynods closed 5 months ago

tynods commented 5 months ago

I am serving a bunch of html pages, including a few images and js files along my main API. I tried mounting those files with dynamicfiles and got unexpected results. In the browser, the first request seems fine but the next ones fail. I got an error telling that there are several Content-Lengh headers... Indeed, upon inspection I noticed that each request adds a pair of Content-Type and Content-Length headers in the response. And there is a mix and match of the several files involved. Some of the headers are related to the HML file and the others to the JS and PNG files.

DId I miss something ? I am new using all this :-/

ndortega commented 5 months ago

Hi @tynods,

Thanks for opening this issue! You've done nothing wrong, this issue stemmed from the way I was trying to append headers without allocating another array or searching for preexisting headers.

Thankfully this is a quick fix, and only requires that I use the HTTP.setheader function to do it properly. This helper function will replace any prexisting header it finds rather than append a duplicate.

Keep an eye out, you should be seeing another patch coming out today!

ndortega commented 5 months ago

Hi @tynods,

I've deployed these changes in the lastest patch v1.4.8 Things should be working as expected, let me know if you run into any other issues