From c8e6b5106fc2302dfde518b176d83c6ca3a61297 Mon Sep 17 00:00:00 2001 From: q4speed Date: Mon, 10 Aug 2020 17:04:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/components/api/test/model/JMX.js | 28 ++++++++----------- .../api/test/model/ScenarioModel.js | 8 +++--- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/frontend/src/business/components/api/test/model/JMX.js b/frontend/src/business/components/api/test/model/JMX.js index 952eb15b62..2b62154c07 100644 --- a/frontend/src/business/components/api/test/model/JMX.js +++ b/frontend/src/business/components/api/test/model/JMX.js @@ -275,29 +275,23 @@ export class DubboSample extends DefaultTestElement { } export class HTTPSamplerProxy extends DefaultTestElement { - constructor(testName, request) { + constructor(testName, options = {}) { super('HTTPSamplerProxy', 'HttpTestSampleGui', 'HTTPSamplerProxy', testName); - this.request = request || {}; - if (request.useEnvironment) { - this.stringProp("HTTPSampler.domain", request.domain); - this.stringProp("HTTPSampler.protocol", request.protocol); - this.stringProp("HTTPSampler.path", this.request.path); - } else { - this.stringProp("HTTPSampler.domain", this.request.hostname); - this.stringProp("HTTPSampler.protocol", this.request.protocol.split(":")[0]); - this.stringProp("HTTPSampler.path", this.request.pathname); - } - this.stringProp("HTTPSampler.method", this.request.method); - this.stringProp("HTTPSampler.contentEncoding", this.request.encoding, "UTF-8"); - if (!this.request.port) { + this.stringProp("HTTPSampler.domain", options.domain); + this.stringProp("HTTPSampler.protocol", options.protocol); + this.stringProp("HTTPSampler.path", options.path); + + this.stringProp("HTTPSampler.method", options.method); + this.stringProp("HTTPSampler.contentEncoding", options.encoding, "UTF-8"); + if (!options.port) { this.stringProp("HTTPSampler.port", ""); } else { - this.stringProp("HTTPSampler.port", this.request.port); + this.stringProp("HTTPSampler.port", options.port); } - this.boolProp("HTTPSampler.follow_redirects", this.request.follow, true); - this.boolProp("HTTPSampler.use_keepalive", this.request.keepalive, true); + this.boolProp("HTTPSampler.follow_redirects", options.follow, true); + this.boolProp("HTTPSampler.use_keepalive", options.keepalive, true); } } diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index d4f6f75585..e02948cd16 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -691,14 +691,14 @@ class JMXHttpRequest { request.url = 'http://' + request.url; } let url = new URL(request.url); - this.hostname = decodeURIComponent(url.hostname); + this.domain = decodeURIComponent(url.hostname); this.port = url.port; this.protocol = url.protocol.split(":")[0]; - this.pathname = this.getPostQueryParameters(request, decodeURIComponent(url.pathname)); + this.path = this.getPostQueryParameters(request, decodeURIComponent(url.pathname)); } else { + this.domain = environment.domain; this.port = environment.port; this.protocol = environment.protocol; - this.domain = environment.domain; let url = new URL(environment.protocol + "://" + environment.socket); this.path = this.getPostQueryParameters(request, decodeURIComponent(url.pathname + (request.path ? request.path : ''))); } @@ -717,7 +717,7 @@ class JMXHttpRequest { for (let i = 0; i < parameters.length; i++) { let parameter = parameters[i]; path += (parameter.name + '=' + parameter.value); - if (i != parameters.length - 1) { + if (i !== parameters.length - 1) { path += '&'; } }