From a4c1d2d9c2cee7b7809093f5da3ca294a99ad463 Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Wed, 24 Feb 2021 22:36:40 +0100 Subject: [PATCH] Fixing output endpoint in unsafe request without host header --- v2/pkg/protocols/http/raw/raw.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/v2/pkg/protocols/http/raw/raw.go b/v2/pkg/protocols/http/raw/raw.go index ff8b85f8f..8030925f8 100644 --- a/v2/pkg/protocols/http/raw/raw.go +++ b/v2/pkg/protocols/http/raw/raw.go @@ -33,7 +33,6 @@ func Parse(request, baseURL string, unsafe bool) (*Request, error) { request = strings.ReplaceAll(request, "\\r", "\r") request = strings.ReplaceAll(request, "\\n", "\n") rawRequest.UnsafeRawBytes = []byte(request) - return rawRequest, nil } reader := bufio.NewReader(strings.NewReader(request)) s, err := reader.ReadString('\n') @@ -43,7 +42,7 @@ func Parse(request, baseURL string, unsafe bool) (*Request, error) { parts := strings.Split(s, " ") //nolint:gomnd // this is not a magic number - if len(parts) < 3 { + if len(parts) < 3 && !unsafe { return nil, fmt.Errorf("malformed request supplied") } // Set the request Method @@ -98,7 +97,7 @@ func Parse(request, baseURL string, unsafe bool) (*Request, error) { rawRequest.Path = parts[1] rawRequest.Headers["Host"] = parsed.Host - } else { + } else if len(parts) > 1 { rawRequest.Path = parts[1] }