Skip to content

Commit 5a31d43

Browse files
committed
✨ XMLHttpRequest: Handle FormData body
1 parent 8edbfc8 commit 5a31d43

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

polyfill/XMLHttpRequest.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget {
170170
log.verbose('sending request with args', _method, _url, _headers, body);
171171
log.verbose(typeof body, body instanceof FormData);
172172

173+
if (body instanceof FormData) {
174+
log.debug('creating blob and setting header from FormData instance');
175+
body = new Blob(body);
176+
this._headers['Content-Type'] = `multipart/form-data; boundary=${body.multipartBoundary}`;
177+
}
178+
173179
if (body instanceof Blob) {
174180
log.debug('sending blob body', body._blobCreated);
175181
promise = new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)