Commit 973fac66 authored by Fernando's avatar Fernando

Refactor HTTP Request/Response into methods

* Refactor common computed prop logic into methods
parent 94b08103
......@@ -66,38 +66,13 @@ export default {
)?.response;
},
getConstructedRequest() {
const { body, method, url, headers = [] } = this.vulnerability.request;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return method && url && headerLines
? [`${method} ${url}\n`, headerLines, '\n\n', body].join('')
: '';
return this.constructRequest(this.vulnerability.request);
},
getConstructedResponse() {
const {
body,
status_code: statusCode,
reason_phrase: reasonPhrase,
headers = [],
} = this.vulnerability.response;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return statusCode && reasonPhrase && headerLines
? [`${statusCode} ${reasonPhrase}\n`, headerLines, '\n\n', body].join('')
: '';
return this.constructResponse(this.vulnerability.response);
},
getConstructedRecordedResponse() {
const {
body,
status_code: statusCode,
reason_phrase: reasonPhrase,
headers = [],
} = this.recordedMessage;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return statusCode && reasonPhrase && headerLines
? [`${statusCode} ${reasonPhrase}\n`, headerLines, '\n\n', body].join('')
: '';
return this.constructResponse(this.recordedMessage);
},
requestData() {
if (!this.vulnerability.request) {
......@@ -167,6 +142,22 @@ export default {
? headers.map(({ name, value }) => `${name}: ${value}`).join('\n')
: '';
},
constructResponse(response) {
const { body, status_code: statusCode, reason_phrase: reasonPhrase, headers = [] } = response;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return statusCode && reasonPhrase && headerLines
? [`${statusCode} ${reasonPhrase}\n`, headerLines, '\n\n', body].join('')
: '';
},
constructRequest(request) {
const { body, method, url, headers = [] } = request;
const headerLines = this.getHeadersAsCodeBlockLines(headers);
return method && url && headerLines
? [`${method} ${url}\n`, headerLines, '\n\n', body].join('')
: '';
},
},
};
</script>
......
import { s__, __ } from '~/locale';
import { s__ } from '~/locale';
export const VULNERABILITY_STATE_OBJECTS = {
detected: {
......@@ -67,5 +67,5 @@ export const REGEXES = {
};
export const SUPPORTING_MESSAGE_TYPES = {
RECORDED: __('Recorded'),
RECORDED: s__('VulnerabilityManagement|Recorded'),
};
......@@ -21945,9 +21945,6 @@ msgstr ""
msgid "Reconfigure"
msgstr ""
msgid "Recorded"
msgstr ""
msgid "Recover hidden stage"
msgstr ""
......@@ -29649,6 +29646,9 @@ msgstr ""
msgid "VulnerabilityManagement|Needs triage"
msgstr ""
msgid "VulnerabilityManagement|Recorded"
msgstr ""
msgid "VulnerabilityManagement|Something went wrong while trying to delete the comment. Please try again later."
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment