From c5e6b49fa6502cde39c253c57a39e8ec7012d36a Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 25 Mar 2018 13:55:31 +0200 Subject: [PATCH] [lib.client.xhr] now @http_token is send by the request itself --- webpack/lib/client/xhr.js | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/webpack/lib/client/xhr.js b/webpack/lib/client/xhr.js index cda11b4..f638a7e 100644 --- a/webpack/lib/client/xhr.js +++ b/webpack/lib/client/xhr.js @@ -26,7 +26,6 @@ export default class XHRClientDriver extends ClientDriver{ /* (1) Create useful attributes */ this.xhr = null; - this.http_token = null; /* (2) Manage _resource format (remove http://, https://) */ this.resource = _resource.replace(/^https?:\/\//, ''); @@ -110,6 +109,12 @@ export default class XHRClientDriver extends ClientDriver{ return false; } + /* (3) Default @http_token value */ + let http_token = null; + if( typeof _request.http_token === 'string' ) + http_token = _request.http_token; + + /* (2) Manage _request.path argument ---------------------------------------------------------*/ /* (1) Error: invalid path format */ @@ -144,14 +149,14 @@ export default class XHRClientDriver extends ClientDriver{ /* (4) Open connection ---------------------------------------------------------*/ - /* (1) Build full URL */ - let request_url = this.resource.split(/\/$/).concat(http_uri.split(/^\//)).filter((v) => v.trim().length).join('/'); + /* (1) Build full request URI */ + let request_uri = this.resource.split(/\/$/).concat(http_uri.split(/^\//)).filter((v) => v.trim().length).join('/'); - /* (2) Build protocol (http, https) */ - let protocol = this.http_token != null ? `${this.proto}${this.http_token}@` : this.proto; + /* (2) Build protocol (http, https) and http_token */ + let protocol = http_token != null ? `${this.proto}${http_token}@` : this.proto; /* (3) Open connection */ - this.xhr.open(http_method, `${protocol}${request_url}`, true); + this.xhr.open(http_method, `${protocol}${request_uri}`, true); /* (3) Send request */ this.xhr.send(form_data); @@ -161,19 +166,4 @@ export default class XHRClientDriver extends ClientDriver{ } - /* (4) Set HTTP token - * - * @_token HTTP token - * - ---------------------------------------------------------*/ - setHttpToken(_token=null){ - - /* Manage _token default values */ - if( typeof _token === 'string' ) - this.http_token = _token; - else - this.http_token = null; - } - - } \ No newline at end of file