-
Notifications
You must be signed in to change notification settings - Fork 355
Open
Description
Description
The native fetch implemented in a browser (along with node-fetch) provide a complex behaviour when processing body. Namely, in case body is a URLSearchParams object, it adds this header 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' to the request and also serializes the corresponding form data.
The problem is that when intersecting the native fetch, Polly doesn't handle this case sending an empty body and a missing type header. Here's a link to the spec.
Shareable Source
const args = {
username: 'username',
password: 'password',
};
fetch('/api/v1/user/login', {
method: 'POST',
headers: {},
body: new URLSearchParams(args),
})The request above is incorrectly handled by Pollyjs, here's the har content for this request:
"postData": {
"mimeType": "text/plain",
"params": []
},as opposed to what's there when I export Network activity into har in Chrome:
"postData": {
"mimeType": "application/x-www-form-urlencoded;charset=UTF-8",
"text": "username=username&password=password",
"params": [
{
"name": "username",
"value": "username"
},
{
"name": "password",
"value": "password"
}
]
}Should Pollyjs also handle this case?
Metadata
Metadata
Assignees
Labels
No labels