mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-09-07 18:02:42 +00:00
Don't override a user-defined content-type header
This commit is contained in:
parent
0814d643c1
commit
5809088f27
@ -249,20 +249,28 @@ class Monitor extends BeanModel {
|
|||||||
|
|
||||||
log.debug("monitor", `[${this.name}] Prepare Options for axios`);
|
log.debug("monitor", `[${this.name}] Prepare Options for axios`);
|
||||||
|
|
||||||
// Set content-type header and body values based on the httpBodyEncoding type selected
|
|
||||||
// TODO: Check if this.headers already contains a content-type header set by the user; if so, don't inject one
|
|
||||||
|
// Check if this.headers already contains a content-type header set by the user; if so, don't inject one
|
||||||
|
let contentTypeUserDefinedHeader = this.headers.find(function(header) {
|
||||||
|
return header[0].toLowerCase() == "content-type";
|
||||||
|
});
|
||||||
|
|
||||||
|
let contentType = contentTypeUserDefinedHeader ?
|
||||||
|
contentTypeUserDefinedHeader[1] :
|
||||||
|
null;
|
||||||
|
|
||||||
let bodyValue = null;
|
let bodyValue = null;
|
||||||
let contentType = null;
|
|
||||||
|
|
||||||
if (this.body && !this.httpBodyEncoding || this.httpBodyEncoding === "json") {
|
if (this.body && !this.httpBodyEncoding || this.httpBodyEncoding === "json") {
|
||||||
bodyValue = JSON.parse(this.body);
|
bodyValue = JSON.parse(this.body);
|
||||||
contentType = "application/json";
|
contentType = contentType ? contentType : "application/json";
|
||||||
} else if (this.body && (this.httpBodyEncoding === "xml")) {
|
} else if (this.body && (this.httpBodyEncoding === "xml")) {
|
||||||
bodyValue = this.body;
|
bodyValue = this.body;
|
||||||
contentType = "text/xml";
|
contentType = contentType ? contentType : "text/xml";
|
||||||
} else if (this.body && (this.httpBodyEncoding === "form")) {
|
} else if (this.body && (this.httpBodyEncoding === "form")) {
|
||||||
bodyValue = this.body;
|
bodyValue = this.body;
|
||||||
contentType = "application/x-www-form-urlencoded";
|
contentType = contentType ? contentType : "application/x-www-form-urlencoded";
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
|
Loading…
Reference in New Issue
Block a user