Jelajahi Sumber

Match the whatwg spec

Steven Silvester 7 tahun lalu
induk
melakukan
b945c6d733

+ 1 - 1
packages/services/src/builder/index.ts

@@ -69,7 +69,7 @@ class BuildManager {
   build(): Promise<void> {
     const base = this.serverSettings.baseUrl;
     const url = URLExt.join(base, BUILD_SETTINGS_URL);
-    const request = { method: 'POST', url };
+    const request = { method: 'POST', url, contentType: 'application/json' };
     const { serverSettings } = this;
     const promise = ServerConnection.makeRequest(request, serverSettings);
 

+ 2 - 1
packages/services/src/config/index.ts

@@ -148,7 +148,8 @@ class DefaultConfigSection implements IConfigSection {
     let request = {
       url: this._url,
       method: 'PATCH',
-      data: JSON.stringify(newdata)
+      data: JSON.stringify(newdata),
+      contentType: 'application/json'
     };
     return ServerConnection.makeRequest(request, this.serverSettings).then(response => {
       if (response.xhr.status !== 200) {

+ 1 - 0
packages/services/src/contents/index.ts

@@ -980,6 +980,7 @@ class Drive implements Contents.IDrive {
       url: this._getUrl(options.path || ''),
       method: 'POST',
       data,
+      contentType: 'application/json'
     };
     return ServerConnection.makeRequest(request, this.serverSettings).then(response => {
       if (response.xhr.status !== 201) {

+ 1 - 0
packages/services/src/kernel/default.ts

@@ -1299,6 +1299,7 @@ namespace Private {
       url: URLExt.join(settings.baseUrl, KERNEL_SERVICE_URL),
       method: 'POST',
       data: JSON.stringify({ name: options.name }),
+      contentType: 'application/json',
       cache: false
     };
     return ServerConnection.makeRequest(request, settings).then(response => {

+ 2 - 2
packages/services/src/serverconnection.ts

@@ -93,14 +93,14 @@ namespace ServerConnection {
     dataType?: string;
 
     /**
-     * The outgoing content type, used to set the `Content-Type` header.  Defaults to `'application/json'` when there is sent data.
+     * The outgoing content type, used to set the `Content-Type` header.
      */
     contentType?: string;
 
     /**
      * The request data.
      */
-    data?: any;
+    data?: Blob | BufferSource | FormData | URLSearchParams | ReadableStream | string;
 
     /**
      * Whether to cache the response. Defaults to `false`.

+ 3 - 1
packages/services/src/session/default.ts

@@ -343,6 +343,7 @@ class DefaultSession implements Session.ISession {
       url: Private.getSessionUrl(settings.baseUrl, this._id),
       method: 'PATCH',
       data,
+      contentType: 'application/json',
       cache: false
     };
     return ServerConnection.makeRequest(request, settings).then(response => {
@@ -712,7 +713,8 @@ namespace Private {
       url: URLExt.join(settings.baseUrl, SESSION_SERVICE_URL),
       method: 'POST',
       cache: false,
-      data: JSON.stringify(model)
+      data: JSON.stringify(model),
+      contentType: 'application/json'
     };
     return ServerConnection.makeRequest(request, settings).then(response => {
       if (response.xhr.status !== 201) {

+ 1 - 0
packages/services/src/setting/index.ts

@@ -77,6 +77,7 @@ class SettingManager {
     const base = this.serverSettings.baseUrl;
     const request = {
       data: JSON.stringify(user),
+      contentType: 'application/json',
       method: 'PATCH',
       url: Private.url(base, id)
     };