Add headers parameter for URL STL load

This commit is contained in:
Albert Møller Nielsen 2022-10-06 00:13:04 +02:00 • committed by GitHub
commit f0c85a0585
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -328,7 +328,7 @@ function platformLoad(url, onload) {
}
}
function platformLoadSTL(url, onload, formdata, credentials) {
function platformLoadSTL(url, onload, formdata, credentials, headers) {
new load.STL().load(url, (vertices, filename) => {
if (vertices) {
let widget = newWidget().loadVertices(vertices);
@ -338,7 +338,7 @@ function platformLoadSTL(url, onload, formdata, credentials) {
onload(vertices, widget);
}
}
}, formdata, 1 / api.view.unit_scale(), credentials);
}, formdata, 1 / api.view.unit_scale(), credentials, headers);
}
function platformLoadURL(url, options = {}) {

View file

@ -23,13 +23,14 @@ function STL() {
this.colors = null;
}
SP.load = function(url, callback, formdata, scale, credentials) {
SP.load = function(url, callback, formdata, scale, credentials, headers) {
const stl = this;
fetch(url, {
method: formdata ? 'POST' : 'GET',
credentials: credentials ? credentials : 'same-origin',
body: formdata
body: formdata,
...(headers ? {headers: headers} : {})
}).then(response => {
if (response.status === 200 || response.status === 0) {
response.arrayBuffer().then(buffer => {