Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Length header always zero? #104

Closed
disleyland opened this issue Mar 10, 2020 · 1 comment
Closed

Content-Length header always zero? #104

disleyland opened this issue Mar 10, 2020 · 1 comment

Comments

@disleyland
Copy link

in migrating to Julia 1+, i find Mux always serves headers with content-length set to zero (which means my download progress widgets are broken). Is there a new setting to re-enable Mux (or HTTP.jl) to send the computed file size in the headers?

@disleyland
Copy link
Author

after some research and testing figured it out. seems we have to manually configure these things now in mux.

using Mux, HttpCommon,JSON

function mycustomheaders(str)
headers = HttpCommon.headers();
headers["Content-Length"] = JSON.json(sizeof(str)); #note use sizeof not length!
Dict(:headers => headers,:body=> str);
end

function testfunc(req)
return "some big file to test content length here"
end

@app service = (
Mux.defaults,
page("/demo", req -> mycustomheaders(testfunc(req))),
Mux.notfound()
)

serve(service,7777)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant