Coder Social home page Coder Social logo

Comments (4)

seankhliao avatar seankhliao commented on May 28, 2024

I believe the comment preceding the line sufficiently explains why it isn't set.

from go.

paralin avatar paralin commented on May 28, 2024

@seankhliao It does not sufficiently cover it. The comment even says within that this is a hacky fix.

I am raising a situation where this needs to be set and there should be some kind of way to force that code branch to not be taken.

from go.

paralin avatar paralin commented on May 28, 2024

CC @neild who introduced this check & the comment: fdc21f3

from go.

Jorropo avatar Jorropo commented on May 28, 2024

I don't find the comment above this if to be clear.


@paralin your code is incorrect, Range gives offsets in the plaintext, not compressed archive, however because you give the already compressed archive to net/http's ranging code, it will interpret them as offsets into the archive and answer with invalid truncated brotli streams no valid client would know to do anything with.

Your best bet is to not use http.FS and use a custom handler instead,
short as an if check on Accept-Encoding, then grab the compressed archive, set Content-Length to the compressed size, write status and finally io.Copy.
If you also want to support Range, then you can use the same thing as above, but also send Accept-Ranges: bytes and then add one more if which instead call http.ServeFile with the plaintext if Range header is set.

from go.

Related Issues (20)

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.