diff --git a/v2/pkg/protocols/http/build_request.go b/v2/pkg/protocols/http/build_request.go index 6808aab6..11467de6 100644 --- a/v2/pkg/protocols/http/build_request.go +++ b/v2/pkg/protocols/http/build_request.go @@ -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) } diff --git a/v2/pkg/protocols/http/raw/raw.go b/v2/pkg/protocols/http/raw/raw.go index 5fb5d8ba..698e1cb8 100644 --- a/v2/pkg/protocols/http/raw/raw.go +++ b/v2/pkg/protocols/http/raw/raw.go @@ -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 } diff --git a/v2/pkg/protocols/http/utils.go b/v2/pkg/protocols/http/utils.go index 97c8044f..6c198556 100644 --- a/v2/pkg/protocols/http/utils.go +++ b/v2/pkg/protocols/http/utils.go @@ -139,6 +139,5 @@ func rawHasBody(data string) bool { if err != nil { return false } - return len(body) > 0 }