From 9e9182bd54b25358505cc16a06585b8426644f81 Mon Sep 17 00:00:00 2001 From: Yangjing Zhang Date: Fri, 13 Dec 2024 13:54:15 +0800 Subject: [PATCH] Fix 'nil pointer dereference' --- headers_inspection_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/headers_inspection_handler.go b/headers_inspection_handler.go index 34ddb19..d02033e 100644 --- a/headers_inspection_handler.go +++ b/headers_inspection_handler.go @@ -104,6 +104,9 @@ func (middleware HeadersInspectionHandler) Intercept(pipeline Pipeline, middlewa } } response, err := pipeline.Next(req, middlewareIndex) + if err != nil { + return response, err + } if reqOption.GetInspectResponseHeaders() { for k, v := range response.Header { if len(v) == 1 { @@ -113,8 +116,5 @@ func (middleware HeadersInspectionHandler) Intercept(pipeline Pipeline, middlewa } } } - if err != nil { - return response, err - } return response, err }