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

generate etags for binary responses #1381

Closed
wants to merge 1 commit into from
Closed

generate etags for binary responses #1381

wants to merge 1 commit into from

Conversation

Rich-Harris
Copy link
Member

#1136. seeing some test failures that I can't explain so I'm not going to merge this, instead I'm going to reimplement it more carefully. Just leaving this here for reference.

it involves a few changes:

  • separating ServerResponse from the new EndpointOutput type (both types are public)
  • ServerResponse body can be string or Uint8Array (the latter only/always when content-type is application/octet-stream)
  • EndpointOutput body can also be a JSONValue
  • handle response must be ServerResponse (i.e. body must be string or Uint8Array here, not JSONValue)
  • rawBody can be string or Uint8Array (less sure about this bit)

Aside: brilliantly, in Node, when you call res.end(uint8Array) you get the following error:

The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Uint8Array

Slow clap. It turns out you can do res.write(uint8Array), res.end() though.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts

@Rich-Harris
Copy link
Member Author

closing in favour of #1382

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.

1 participant