Comments (4)
I believe the comment preceding the line sufficiently explains why it isn't set.
from go.
@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.
CC @neild who introduced this check & the comment: fdc21f3
from go.
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)
- crypto/internal/mlkem768: TestPQCrystalsAccumulated fails on linux/s390x HOT 4
- Reconsider issue #226 - recurse anonymous function / declare named closure HOT 1
- net/http: Last-Modified header did not correctly check the time HOT 2
- x/tools/gopls: Missing semantic tokens in the declaration of function type variables HOT 1
- archive/zip: `Create()` does not overwrite duplicate filenames, leading to unnecessary bloating of the resulting ZIP file HOT 2
- x/net/http2: response Write on HEAD fails with "http2: request body closed due to handler exiting" HOT 11
- all: end support for Windows 10 <= 22H2, Windows Server 2016/2019 in Go 1.23 HOT 4
- path/filepath: Ext returns file name as extension for hidden files on Linux/Unix HOT 1
- proposal: x/crypto/ssh: allow to change allowed authentication methods HOT 3
- proposal: crypto/rand: crash process on error reading randomness HOT 14
- runtime,reflect: reflect.bitVector and runtime.bitvector not sync HOT 3
- proposal: x/crypto/ssh: add NewServerConnContext HOT 2
- cmd/test2json: go test -bench -json -count output is inconsistent HOT 1
- cmd/compile: missed trivial bound check elimination HOT 7
- x/tools/gopls: go to definition within imported modules HOT 6
- . HOT 1
- -
- archive/{zip,tar}: (*Writer).AddFS omits empty directories HOT 2
- cmd/go: support both .netrc and _netrc under windows HOT 1
- In arm64 environment, c# calls go dll exception HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go.