mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-02 06:26:06 -04:00
Merge pull request #2610 from bayramberkay/feature/add-xml-support-to-http-monitors
Add xml support to HTTP monitors
This commit is contained in:
commit
cecb0b6425
6 changed files with 58 additions and 6 deletions
|
@ -111,6 +111,7 @@ class Monitor extends BeanModel {
|
|||
radiusCalledStationId: this.radiusCalledStationId,
|
||||
radiusCallingStationId: this.radiusCallingStationId,
|
||||
game: this.game,
|
||||
httpBodyEncoding: this.httpBodyEncoding
|
||||
};
|
||||
|
||||
if (includeSensitiveData) {
|
||||
|
@ -272,17 +273,29 @@ class Monitor extends BeanModel {
|
|||
|
||||
log.debug("monitor", `[${this.name}] Prepare Options for axios`);
|
||||
|
||||
let contentType = null;
|
||||
let bodyValue = null;
|
||||
|
||||
if (this.body && !this.httpBodyEncoding || this.httpBodyEncoding === "json") {
|
||||
bodyValue = JSON.parse(this.body);
|
||||
contentType = "application/json";
|
||||
} else if (this.body && (this.httpBodyEncoding === "xml")) {
|
||||
bodyValue = this.body;
|
||||
contentType = "text/xml; charset=utf-8";
|
||||
}
|
||||
|
||||
// Axios Options
|
||||
const options = {
|
||||
url: this.url,
|
||||
method: (this.method || "get").toLowerCase(),
|
||||
...(this.body ? { data: JSON.parse(this.body) } : {}),
|
||||
...(bodyValue ? { data: bodyValue } : {}),
|
||||
timeout: this.interval * 1000 * 0.8,
|
||||
headers: {
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"User-Agent": "Uptime-Kuma/" + version,
|
||||
...(this.headers ? JSON.parse(this.headers) : {}),
|
||||
...(contentType ? { "Content-Type": contentType } : {}),
|
||||
...(basicAuthHeader),
|
||||
...(this.headers ? JSON.parse(this.headers) : {})
|
||||
},
|
||||
maxRedirects: this.maxredirects,
|
||||
validateStatus: (status) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue