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

implement sync formdata parser #2911

Merged
merged 11 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup
  • Loading branch information
KhafraDev committed Mar 3, 2024
commit 02b18a01443d49f30739202b87398af0fa081073
5 changes: 4 additions & 1 deletion lib/web/fetch/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ function bodyMixinMethods (instance) {

// 3. Return a new FormData object whose entry list is entries.
const fd = new FormData()
fd[kState] = [...entries]

for (const [name, value] of entries) {
fd.append(name, value)
}

return fd
}
Expand Down
11 changes: 10 additions & 1 deletion test/fetch/client-fetch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals AbortController */

Check failure on line 1 in test/fetch/client-fetch.js

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest)

test/fetch/client-fetch.js

[Error: test failed] { failureType: 'testCodeFailure', cause: 'test failed', code: 'ERR_TEST_FAILURE', exitCode: 1, signal: null }

Check failure on line 1 in test/fetch/client-fetch.js

View workflow job for this annotation

GitHub Actions / test (20, ubuntu-latest)

test/fetch/client-fetch.js

[Error: test failed] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: 'test failed', exitCode: 1, signal: null }

Check failure on line 1 in test/fetch/client-fetch.js

View workflow job for this annotation

GitHub Actions / test (21, ubuntu-latest)

test/fetch/client-fetch.js

[Error: test failed] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: 'test failed', exitCode: 1, signal: null }

'use strict'

Expand Down Expand Up @@ -213,7 +213,16 @@

// Example form data with base64 encoding
const data = randomFillSync(Buffer.alloc(256))
const formRaw = `------formdata-undici-0.5786922755719377\r\nContent-Disposition: form-data; name="file"; filename="test.txt"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: base64\r\n\r\n${data.toString('base64')}\r\n------formdata-undici-0.5786922755719377--`
const formRaw =
'------formdata-undici-0.5786922755719377\r\n' +
'Content-Disposition: form-data; name="file"; filename="test.txt"\r\n' +
'Content-Type: application/octet-stream\r\n' +
'Content-Transfer-Encoding: base64\r\n' +
'\r\n' +
data.toString('base64') +
'\r\n' +
'------formdata-undici-0.5786922755719377--'

const server = createServer(async (req, res) => {
res.setHeader('content-type', 'multipart/form-data; boundary=----formdata-undici-0.5786922755719377')

Expand Down
Loading