TheWaWaR / simple-http-server

Simple http server in Rust (Windows/Mac/Linux)
MIT License
2.53k stars 170 forks source link

Downloading files with space in name fails #105

Closed CY-Pan closed 4 months ago

CY-Pan commented 4 months ago

I've been using this great tool for some time to move files from my laptop to my Android device. One day I found some of the files just disappear from my Android Chrome's list during downloading, without any success message or failure warning. After several tests, I find this problem occurs on file with space in its name, such as "Sample 1.mp4".

I know the problem of file disappearing should be bugs in Chrome. But I'm curious on the downloading procedure of this tool. When I download a large file through this tool, the client first sends request to the server and gets 200 reply. But later, it seems to request the file again and gets 206 reply. Snipaste_2024-02-23_10-02-28

On the contrary, if I download the file through Python's http server, it's only one request and one reply. (Both cases are tested with same Android Chrome) Snipaste_2024-02-23_10-07-19

I'm wondering why their download processes differ in this way. Also, through observation, I found the download issue occurs at the time the client requests the file again and gets 206 reply. Is there possibly a command option to make this tool behave like Python's http server with exactly 1 request and 1 reply?

TheWaWaR commented 4 months ago

HTTP code 206 is a Partial Content success status. If you want to disable it, just passing --norange in command line argument.

simple-http-server --norange

I recommend you don't disable this option, especially when download large file, it can continue download from last failed download process. If you disable it and the download process stopped by some condition you need download the file from start again.