When a visitor taps download on ramrom.io, my PHP proxy fetches the video file from the provider and streams it straight through to their browser. Most of the time the provider sends a Content-Length header with the file, so the browser knows how big it is and can draw a proper progress bar. Sometimes it does not. The response just starts sending bytes and never says how many are coming. That is the case I want to talk about, because it is where a lot of downloaders quietly lie to the user.
So here is what the proxy actually does. When the provider response arrives, I check for Content-Length first. If it is there and it is a sane number, I pass it through untouched, along with the Content-Type and a Content-Disposition: attachment header so the browser saves the file instead of playing it. The visitor gets a real progress bar, driven by the browser, and I have done nothing clever.
If the header is missing, I do two honest things instead of one dishonest one. First, I stream the file in chunks with fread and flush the output as I go, so the download starts immediately and the visitor sees bytes arriving rather than a blank wait. Second, I say so on the page before the download starts: the file size is shown as "unknown" and the button changes to "Downloading…" with a note that the size was not given by the source. No bar, no percentage, no fake estimate. The browser itself usually shows a spinner and a running byte count in its own downloads panel, which is a true number — bytes received so far — and that is enough.
Some providers send a Content-Length that is wrong: the header promises 12 MB and the body stops at 9 MB. I cannot fix a lying header, but I can stop trusting it blindly. My proxy checks the stream as it reads and never claims the download is complete until the provider closes the connection cleanly. If the stream ends early, the visitor gets an honest error — "the file stopped partway through, please try again" — instead of a truncated MP4 that will not play and that they will blame on their phone.
One more detail: I never buffer the whole file in memory to find out its size. On shared hosting with a modest memory_limit, holding a 500 MB video in RAM would kill the process before the first byte reached the visitor. The stream is read in 8 KB chunks and written out as it goes, so memory usage stays flat no matter how big the file is. That is also why I cannot know the size in advance — the only way to measure the file would be to download it first and store it, which I refuse to do. Files pass through my server and are never saved on it, and that privacy rule means the size is genuinely unknowable when the provider stays silent.
The lesson is small but it generalises: when a tool has to show a number it does not have, the honest options are "unknown" or the only true number available — bytes so far. A progress bar that moves on a guess is not progress, it is theatre, and on a tool people use for ten seconds at a time, theatre is the fastest way to lose their trust. The next time your download shows no size and no bar, that is not a bug I missed. It is the one place where I chose to tell the truth instead.
