Skip to content

Commit d007bbc

Browse files
committed
Fix missing content type headers
1 parent aa77bcd commit d007bbc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/io/files.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
/* globals Request: false */
9+
/* globals Headers: false */
910

1011
'use strict';
1112

@@ -863,6 +864,7 @@ p5.prototype.httpDo = function () {
863864
var request;
864865
var jsonpOptions = {};
865866
var cbCount = 0;
867+
var contentType = 'text/plain';
866868
// Trim the callbacks off the end to get an idea of how many arguments are passed
867869
for (var i = arguments.length-1; i > 0; i--){
868870
if(typeof arguments[i] === 'function'){
@@ -914,6 +916,7 @@ p5.prototype.httpDo = function () {
914916
}
915917
}else{
916918
data = JSON.stringify(a);
919+
contentType = 'application/json';
917920
}
918921
} else if (typeof a === 'function') {
919922
if (!callback) {
@@ -937,7 +940,10 @@ p5.prototype.httpDo = function () {
937940
request = new Request(path, {
938941
method: method,
939942
mode: 'cors',
940-
body: data
943+
body: data,
944+
headers: new Headers({
945+
'Content-Type': contentType
946+
})
941947
});
942948
}
943949

0 commit comments

Comments
 (0)