From ab19e2d4293d870b1f06a9a672cdd8ad62f97f32 Mon Sep 17 00:00:00 2001 From: "Plushnikov, Michail" Date: Fri, 13 Dec 2024 15:06:31 +0100 Subject: [PATCH] fix(RELTEC-12253): prevent nil pointer reference in RoundTripper --- implementation/capture/roundtripper.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/implementation/capture/roundtripper.go b/implementation/capture/roundtripper.go index 2dce3cc..7346da5 100644 --- a/implementation/capture/roundtripper.go +++ b/implementation/capture/roundtripper.go @@ -23,8 +23,11 @@ func (c *RequestCaptureImpl) RoundTrip(req *http.Request) (*http.Response, error err := c.Wrapped.Perform(req.Context(), req.Method, req.URL.String(), req.Body, &parsedResponse) - newReader := strings.NewReader(string(**(parsedResponse.Body.(**[]byte)))) - readCloser := io.NopCloser(newReader) + var readCloser io.ReadCloser + if parsedResponse.Body != nil { + newReader := strings.NewReader(string(**(parsedResponse.Body.(**[]byte)))) + readCloser = io.NopCloser(newReader) + } return &http.Response{ Status: "",