Compare commits

..
4 Commits
Author SHA1 Message Date
Tony West 8e2e5fbebc Fixed improper handling of base path 2026-01-15 10:54:22 -05:00
Tony West a77f9f46bb Merge pull request #49 from altperfect/main
Prevent header-processing logic from dropping custom headers in 'automate' mode
2026-01-15 10:37:28 -05:00
altperfect 5554e2bd30 fix: prevent header-processing logic from dropping custom headers 2026-01-15 19:08:39 +05:00
Tony West 09c460e768 Fixed issue that occurred when running against subdomains that contain '-d' in the subdomain name 2025-11-25 16:36:39 -05:00
3 changed files with 16 additions and 18 deletions

No files matched your search

+11 -14
View File
@@ -98,22 +98,19 @@ func MakeRequest(client http.Client, method, target string, timeout int64, reqDa
continue
}
key := Headers[i][:delimIndex]
value := Headers[i][delimIndex+1:]
key := strings.TrimSpace(Headers[i][:delimIndex])
value := strings.TrimSpace(Headers[i][delimIndex+1:])
if len(Headers) == 2 {
if key == "User-Agent" {
UserAgent = value
}
if key == "Content-Type" {
contentType = value
}
if key == "Accept" {
accept = value
}
} else {
req.Header.Set(key, value)
if key == "User-Agent" {
UserAgent = value
}
if key == "Content-Type" {
contentType = value
}
if key == "Accept" {
accept = value
}
req.Header.Set(key, value)
}
// User-Agent handling
+1 -1
View File
@@ -49,7 +49,7 @@ $ sj convert -u https://petstore.swagger.io/v2/swagger.json -o openapi.json`,
log.Error("Command not specified. See the --help flag for usage.")
}
},
Version: "2.0.2",
Version: "2.0.4",
}
func Execute() {
+4 -3
View File
@@ -96,6 +96,8 @@ func GenerateRequests(bodyBytes []byte, client http.Client) {
if serverURL, ok := srv["url"].(string); ok {
if strings.Contains(serverURL, "://") {
apiTarget = serverURL
} else if serverURL == "/" {
basePath = ""
} else {
basePath = serverURL
apiTarget = u.Scheme + "://" + u.Host
@@ -205,7 +207,7 @@ func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client) {
}
if strings.Contains(curl, "-d") {
if strings.Contains(curl, "-d '") {
bodyData += fmt.Sprintf("&%s=%s", propertyItem, pValue)
curl = strings.TrimSuffix(curl, "'")
curl += fmt.Sprintf("&%s=%s'", propertyItem, pValue)
@@ -213,7 +215,6 @@ func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client) {
bodyData += fmt.Sprintf("%s=%s", propertyItem, pValue)
curl += fmt.Sprintf(" -d '%s=%s'", propertyItem, pValue)
}
}
}
}
@@ -242,7 +243,7 @@ func BuildRequestsFromPaths(spec map[string]interface{}, client http.Client) {
case "header":
curl += fmt.Sprintf(" -H \"%s: %s\"", name, pValue)
case "body":
if strings.Contains(curl, "-d") {
if strings.Contains(curl, "-d '") {
bodyData += fmt.Sprintf("&%s=%s", name, pValue)
curl = strings.TrimSuffix(curl, "'")
curl += fmt.Sprintf("&%s=%s'", name, pValue)