From 61313d86e0d7d4e8872beb5889aefcf14b65cad9 Mon Sep 17 00:00:00 2001 From: Joe Andaverde Date: Wed, 23 Feb 2022 16:09:57 -0600 Subject: [PATCH] Set header content type instead of overwriting all headers (#14222) * Set header content type instead of overwriting all headers * Add changelog file --- api/logical.go | 5 +---- changelog/14222.txt | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 changelog/14222.txt diff --git a/api/logical.go b/api/logical.go index 68f3e9100..f7d2b4a40 100644 --- a/api/logical.go +++ b/api/logical.go @@ -5,7 +5,6 @@ import ( "context" "fmt" "io" - "net/http" "net/url" "os" "strings" @@ -145,9 +144,7 @@ func (c *Logical) Write(path string, data map[string]interface{}) (*Secret, erro func (c *Logical) JSONMergePatch(ctx context.Context, path string, data map[string]interface{}) (*Secret, error) { r := c.c.NewRequest("PATCH", "/v1/"+path) - r.Headers = http.Header{ - "Content-Type": []string{"application/merge-patch+json"}, - } + r.Headers.Set("Content-Type", "application/merge-patch+json") if err := r.SetJSONBody(data); err != nil { return nil, err } diff --git a/changelog/14222.txt b/changelog/14222.txt new file mode 100644 index 000000000..3d9cfb10b --- /dev/null +++ b/changelog/14222.txt @@ -0,0 +1,3 @@ +```release-note: bug +core/api: Fix overwriting of request headers when using JSONMergePatch. +```