This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 578180f  Remove unneeded WriteHeader (#6507)
578180f is described below

commit 578180f212cedec86f3cb74a814747cf36d005d4
Author: Steve Hamrick <[email protected]>
AuthorDate: Thu Jan 13 15:49:12 2022 -0700

    Remove unneeded WriteHeader (#6507)
    
    * Remove unneeded WriteHeader
    
    * Fix tests
---
 traffic_ops/traffic_ops_golang/api/api.go                          | 1 -
 traffic_ops/traffic_ops_golang/routing/middleware/wrappers_test.go | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/api/api.go 
b/traffic_ops/traffic_ops_golang/api/api.go
index 471b04a..ff66ceb 100644
--- a/traffic_ops/traffic_ops_golang/api/api.go
+++ b/traffic_ops/traffic_ops_golang/api/api.go
@@ -272,7 +272,6 @@ func handleSimpleErr(w http.ResponseWriter, r 
*http.Request, statusCode int, use
                return
        }
        w.Header().Set(rfc.ContentType, rfc.ApplicationJSON)
-       w.WriteHeader(statusCode)
        WriteAndLogErr(w, r, append(respBts, '\n'))
 }
 
diff --git a/traffic_ops/traffic_ops_golang/routing/middleware/wrappers_test.go 
b/traffic_ops/traffic_ops_golang/routing/middleware/wrappers_test.go
index c9b72d7..ee677e3 100644
--- a/traffic_ops/traffic_ops_golang/routing/middleware/wrappers_test.go
+++ b/traffic_ops/traffic_ops_golang/routing/middleware/wrappers_test.go
@@ -272,7 +272,7 @@ func TestRequiredPermissionsMiddleware(t *testing.T) {
 
        authWrapper := authBase.GetWrapper(0)
 
-       f := 
authWrapper(RequiredPermissionsMiddleware([]string{"foo"})(handler))
+       f := 
authWrapper(WrapHeaders(RequiredPermissionsMiddleware([]string{"foo"})(handler)))
 
        w, r := newRWPair(t, cookie)
 
@@ -351,7 +351,7 @@ func TestConfigRoleBasedPermissionsHandling(t *testing.T) {
        handler := func(w http.ResponseWriter, r *http.Request) {
                w.Write([]byte("successs\n"))
        }
-       f := AuthBase{secret, 
nil}.GetWrapper(5)(RequiredPermissionsMiddleware([]string{"foo"})(handler))
+       f := WrapHeaders(AuthBase{secret, 
nil}.GetWrapper(5)(RequiredPermissionsMiddleware([]string{"foo"})(handler)))
 
        w, r := newRWPair(t, cookie)
        r = r.WithContext(ctx)

Reply via email to