Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow loading gzipped fixtures #644

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

achingbrain
Copy link
Collaborator

@achingbrain achingbrain commented Feb 8, 2024

Description

When loading a file that ends in .gz, sirv will set the Content-Encoding header to gzip which means browsers will unzip the content before handing it back to fetch or XMLHttpRequest.

This PR adds a workaround to the asset server that sets the header to a garbage value if a file ending in .gz has been requested.

It's necessary to use a garbage value because sirv sets the headers after the setHeaders function passed to it's config has been invoked, and it will only not set the header if one has been set already.

Link to issue

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Refactor (non-breaking change that updates existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Comments have been added/updated

When loading a file that ends in `.gz`, `sirv` will set the
`Content-Encoding` header to `gzip` which means browsers will
unzip the content before handing it back to `fetch` or `XMLHttpRequest`.

This PR adds a workaround to the asset server that sets the header
to a garbage value if a file ending in `.gz` has been requested.

It's necessary to use a garbage value because `sirv` will only set
the header if it's not been set already, so we can't simply delete it.

Refs: lukeed/sirv#158
Refs: ipfs/aegir#1462
@hugomrdias hugomrdias merged commit 2764b63 into master Feb 8, 2024
6 checks passed
@hugomrdias hugomrdias deleted the fix/allow-loading-gzipped-fixtures branch February 8, 2024 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants