diff --git a/v2/pkg/protocols/http/build_request.go b/v2/pkg/protocols/http/build_request.go index f32e6151..69d806cf 100644 --- a/v2/pkg/protocols/http/build_request.go +++ b/v2/pkg/protocols/http/build_request.go @@ -108,15 +108,7 @@ 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 trailing line to request body based on content type - // handling multipart bodies differently. - if !strings.HasSuffix(data, "\r\n") && !strings.HasSuffix(data, "\n") { - if !strings.Contains(r.request.Headers["Content-Type"], "multipart") { - data += "\n" - } else { - data += "\r\n" - } - } + data += "\r\n" return r.handleRawWithPaylods(ctx, data, baseURL, values, payloads) } diff --git a/v2/pkg/protocols/http/http.go b/v2/pkg/protocols/http/http.go index 84293409..ee30a1ec 100644 --- a/v2/pkg/protocols/http/http.go +++ b/v2/pkg/protocols/http/http.go @@ -103,6 +103,11 @@ func (r *Request) Compile(options *protocols.ExecuterOptions) error { } if len(r.Raw) > 0 { + for i, raw := range r.Raw { + if !strings.Contains(raw, "\r\n") { + r.Raw[i] = strings.ReplaceAll(raw, "\n", "\r\n") + } + } r.rawhttpClient = httpclientpool.GetRawHTTP() } if len(r.Matchers) > 0 || len(r.Extractors) > 0 {