storj / edge

Storj edge services (including multi-tenant, S3-compatible server to interact with the Storj network)
GNU Affero General Public License v3.0
48 stars 18 forks source link

Linksharing Accept-Encoding parsing needs improvement #377

Closed wthorp closed 7 months ago

wthorp commented 7 months ago

Expected Behavior

Linksharing ZIP support should return compressed content when presented with valid, complex Accept-Encoding strings.

Current Behavior

Linksharing uses simplified Accept-Encoding parsing which does not detect all requests for compressed content.

Possible Solution

Implement more robust Accept-Encoding parsing.

Steps to Reproduce

  1. Send request with Accept-encoding header br;q=1.0, gzip;q=0.8, *;q=0.1 when requesting content from a ZIP file

Context (Environment)

Accept-Encoding is a forbidden HTTP header according to the Fetch spec. Thus it can't be precisely set from Javascript, and instead relies on what the browser sends. This breaks Linksharing's ability to send compressed ZIP content to a browser, as browsers tend to deliver more complex strings.

Detailed Description

Use better Accept-Encoding parser logic instead of https://github.com/storj/edge/blob/0c1c0d33f8330aba580729d7851aa44ddbb475ba/pkg/linksharing/sharing/present.go#L214

Possible Implementation

Another nice-to-have here might be a URL parameter or non-forbidden header to fall back on.

storj-gerrit[bot] commented 7 months ago

Change pkg/linksharing/sharing: extend Accept-Encoding parsing for zip content mentions this issue.