Coder Social home page Coder Social logo

0-byte files cause issues about render HOT 6 CLOSED

kotx avatar kotx commented on September 23, 2024
0-byte files cause issues

from render.

Comments (6)

catharsis71 avatar catharsis71 commented on September 23, 2024 1

I had to flush my cache but yeah now it's a 200 (and now I know caching really is working)

from render.

kotx avatar kotx commented on September 23, 2024

Ah, seems like I need to return null as the response body if the file is 0-length. I'll look into that now.

from render.

kotx avatar kotx commented on September 23, 2024

Fixed by bb39427, thanks!

from render.

catharsis71 avatar catharsis71 commented on September 23, 2024

I've been thinking about this some more

Seems like most web servers serve 0-byte files by responding with a 200 OK with a "content-length: 0". I can't speak for every web server but that's definitely how Apache does it, as well as whatever Github Pages and Cloudflare Pages are running.

Was it a conscious decision to use a 204 No Content for this or are you just getting a 204 from R2 and passing it along?

Would it make more sense to copy how most web servers behave and do it as a 200 OK / content-length: 0? With a 200 OK, you're able to actually browse to a 0-byte file and the browser will show a blank page (unless the server set the content type as application/octet-stream in which case it will treat it as a download), whereas with a 204 No Content, the browser will remain on the page it's on and it will basically seem like nothing happened (regardless of content-type).

another data point: wget will decline to write anything to disk if the server returns a 204 Not Found, whereas with a 200 OK content-length 0, it will write a 0-byte file. So if someone is using wget to spider a site with links to 0-byte files (but with potentially informative filenames), 204's will result in the site not being spidered properly as the 0-byte files won't make it onto disk.

from render.

kotx avatar kotx commented on September 23, 2024

I checked this some more and it seems like 200 is more appropriate. Also I forgot to send Content-Length it seems? I can't fix this now as I'll be busy for the next few days but if you want you can PR this, should be fairly straightforward. Sorry if it causes you any inconvenience.

from render.

kotx avatar kotx commented on September 23, 2024

I believe I've fixed this with c2f347b. Let me know if anything else breaks.

from render.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.