Set explicit `Accept` header in Ajax/Request.ts
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 13 Apr 2023 14:01:52 +0000 (16:01 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 14 Apr 2023 11:54:49 +0000 (13:54 +0200)
ts/WoltLabSuite/Core/Ajax/Request.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js

index d5e09235da41eb766a265f04b3708ea95f905488..4a5021951f348a5de81c86c2381dac99714c8c5a 100644 (file)
@@ -126,6 +126,9 @@ class AjaxRequest {
     if (this._options.withCredentials || this._options.includeRequestedWith) {
       this._xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
     }
+    if (this._options.responseType) {
+      this._xhr.setRequestHeader("Accept", this._options.responseType);
+    }
     if (this._options.withCredentials) {
       this._xhr.withCredentials = true;
     }
index d44b81d35949e2416c65ca6e65c50c0c681178c9..38209795e8b8e3337d72cc5247723c2fb4f1bd8a 100644 (file)
@@ -103,6 +103,9 @@ define(["require", "exports", "tslib", "./Status", "../Core", "../Dom/Change/Lis
             if (this._options.withCredentials || this._options.includeRequestedWith) {
                 this._xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
             }
+            if (this._options.responseType) {
+                this._xhr.setRequestHeader("Accept", this._options.responseType);
+            }
             if (this._options.withCredentials) {
                 this._xhr.withCredentials = true;
             }