-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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: improve getRawBody
parsing & handle error(s)
#1528
Conversation
fulfil(null); | ||
return; | ||
} | ||
const new_len = offset + Buffer.byteLength(chunk); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the chunk.length
was a bug. Incoming chunks
can be strings, but even if they're still Buffer instances, length
is not always the same as byteLength
, which is what content-length
tracks
@@ -48,11 +50,11 @@ export function getRawBody(req) { | |||
const [type] = h['content-type'].split(/;\s*/); | |||
|
|||
if (type === 'application/octet-stream') { | |||
fulfil(data); | |||
return fulfil(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this return
, then decoding continued (below)
lgtm. I wonder if |
I rebased this and am going to go ahead and merge it. We can always add more tests later |
* 'master' of https://github.com/sveltejs/kit: Version Packages (next) (sveltejs#1543) type fixes for adapter-node and adapter-static (sveltejs#1578) Upgrade to Vite 2.3.3 (sveltejs#1580) fix: improve getRawBody parsing & handle error(s) (sveltejs#1528) create-svelte: add svelte-check for TS (sveltejs#1556) pass validated svelte config to adapters (sveltejs#1559) types: group related and reduce potential inconsistencies (sveltejs#1539) Use sveltekit tag on StackOverflow (sveltejs#1558) Fix create-svelte build-template script (sveltejs#1555) Remove err param from Polka .listen() callback (sveltejs#1550) bump: polka and sirv versions (sveltejs#1548) svelte-kit package (sveltejs#1499)
Tests
pnpm test
and lint the project withpnpm lint
Changesets
pnpx changeset
and following the promptsSummary
getRawBody
utility did not handle the case where the supplied body actually exceeds theContent-Length
header. Added that logic. (This is impossible to spoof on Playwright/browser clients. Can add a test once a unit testing system is in place.)octect-stream
request bodies were double-fulfilledrawBody
type interfaces (missingnull
possibility)getRawBody
possible error(s) in consumers/adaptersRelated to (but does not close) #1523