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

Database download missing content-length header and is sent chunked #2317

Open
amoeba opened this issue Apr 6, 2024 · 0 comments
Open

Database download missing content-length header and is sent chunked #2317

amoeba opened this issue Apr 6, 2024 · 0 comments

Comments

@amoeba
Copy link

amoeba commented Apr 6, 2024

With the latest Datasette (0.64.1 or latest git HEAD), when I serve my database like this,

$ datasette serve -i my.db

and try to download from http://127.0.0.1:8001/my.db,

I expect a content-length header since I think I'm downloading a static file from the filesystem but it's not set and the response is chunked instead:

$ curl -I "http://127.0.0.1:8001/my.db"
HTTP/1.1 200 OK
date: Sat, 06 Apr 2024 06:01:16 GMT
server: uvicorn
Etag: "c80e062a22bfff8042d1774f1c839ca3a7d95c53ae03a764fd4f6f1a5cbfd4de"
content-disposition: attachment; filename="my.db"
content-type: application/octet-stream
Transfer-Encoding: chunked

Is there a reason why the response is chunked here and not just sent normally with content-length? I'm guessing timeouts? I see #905 which makes it look like content-length should be getting set but when I attach a debugger the code that gets hit is https://github.com/simonw/datasette/blob/main/datasette/views/database.py#L302 which doesn't set it so I assume there's different code involved.

Setting content-length would be useful for my use-case which involves showing a progress bar for the request. MDN indicates mixing chunked and content-length might be a bad idea but I thought I'd suggest it in case it might work here.

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