Rawhttp fixes, render non-printable chars with unsafe

dev
Ice3man543 2021-02-22 18:22:44 +05:30
parent e70ca44741
commit d541b09928
3 changed files with 7 additions and 5 deletions

View File

@ -114,12 +114,12 @@ func (r *requestGenerator) makeHTTPRequestFromModel(ctx context.Context, data st
// makeHTTPRequestFromRaw creates a *http.Request from a raw request
func (r *requestGenerator) makeHTTPRequestFromRaw(ctx context.Context, baseURL, data string, values, payloads map[string]interface{}) (*generatedRequest, error) {
// add "\r\n" only to RCF compliant requests without body
// Add "\r\n" only to RCF compliant requests without body
if !r.request.Unsafe && !rawHasBody(data) {
data += "\r\n"
} else {
data = strings.TrimSuffix(data, "\r\n")
}
} else {
data = strings.TrimSuffix(data, "\r\n")
}
return r.handleRawWithPaylods(ctx, data, baseURL, values, payloads)
}

View File

@ -29,6 +29,9 @@ func Parse(request, baseURL string, unsafe bool) (*Request, error) {
Headers: make(map[string]string),
}
if unsafe {
request = strings.ReplaceAll(request, "\\0", "\x00")
request = strings.ReplaceAll(request, "\\r", "\r")
request = strings.ReplaceAll(request, "\\n", "\n")
rawRequest.UnsafeRawBytes = []byte(request)
return rawRequest, nil
}

View File

@ -139,6 +139,5 @@ func rawHasBody(data string) bool {
if err != nil {
return false
}
return len(body) > 0
}