File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
src/components/proxy-middleware Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1+
12// import { cloneDeep } from "lodash";
23// import HTTPSnippet from "httpsnippet";
3- import { get_success_actions_from_action_results } from "../rule_action_processor/utils" ;
4+ import { get_success_actions_from_action_results , getHost } from "../rule_action_processor/utils" ;
45import { createHar } from "../helpers/harObectCreator" ;
56// const url = require("url");
67
@@ -15,6 +16,7 @@ class LoggerMiddleware {
1516 return "" ;
1617 }
1718 let requestCurl = "" ;
19+
1820 // try {
1921 // const harObject = cloneDeep(requestHarObject);
2022 // requestCurl = new HTTPSnippet(harObject).convert("shell", "curl", {
@@ -79,7 +81,7 @@ class LoggerMiddleware {
7981 ctx . rq . final_request . headers ,
8082 ctx . rq . final_request . method ,
8183 protocol ,
82- ctx . rq . final_request . host ,
84+ getHost ( ctx ) ,
8385 ctx . rq . final_request . path ,
8486 ctx . rq . final_request . body ,
8587 ctx . rq . final_response . status_code ,
Original file line number Diff line number Diff line change @@ -43,6 +43,20 @@ export const get_success_actions_from_action_results = (
4343 return success_action_results_objs . map ( ( obj ) => obj . action ) ;
4444} ;
4545
46+ export const getHost = ( ctx ) => {
47+ const finalHost = ctx . rq . final_request . host ;
48+ const port = ctx . rq . final_request . port ;
49+ const protocol = ctx . isSSL ? "https" : "http" ;
50+ const standardPort = protocol === "https" ? 443 : 80 ;
51+
52+ // Only append port if it's non-standard and not already in the host
53+ if ( port && port !== standardPort && ! finalHost . includes ( ':' ) ) {
54+ return `${ finalHost } :${ port } ` ;
55+ }
56+
57+ return finalHost ;
58+ }
59+
4660export const get_file_contents = ( file_path ) => {
4761 return fs . readFileSync ( file_path , "utf-8" ) ;
4862}
You can’t perform that action at this time.
0 commit comments