Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 3373bd9

Browse files
authored
let browser generate content-type for sending form-data (#1327)
* let browser generate content-type for sending form-data * tell jquery.ajax to not set default content-type * fix typos fix #1122 fix #1309 fix #1234
1 parent d1410c9 commit 3373bd9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

template/src/send_sample_request.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ function sendSampleRequest (group, name, version, method) {
140140
}
141141
requestParams.data = formData;
142142
requestParams.processData = false;
143-
// GET and DELETE methods do not need content-type
144-
if (method.toLowerCase() === 'get' || method.toLowerCase() === 'delete') {
145-
delete requestParams.headers['Content-Type'];
146-
}
143+
// With no content-type header, browser will know it needs to generate a proper content-type for
144+
// the form data when sending it. Fix #1122
145+
delete requestParams.headers['Content-Type'];
146+
// As of jQuery 1.6 you can pass false to tell jQuery to not set any content type header.
147+
// https://api.jquery.com/jquery.ajax/
148+
requestParams.contentType = false;
147149
}
148150

149151
requestParams.type = method;

0 commit comments

Comments
 (0)