Skip to content

Commit

Permalink
fix(op): initialize http Headers in response objects (#637)
Browse files Browse the repository at this point in the history
* fix(op): initialize http Headers in response objects

* fix test

---------

Co-authored-by: Livio Spring <[email protected]>
  • Loading branch information
muhlemmer and livio-a authored Aug 21, 2024
1 parent 9930193 commit 1e75773
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/op/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ func TestTryErrorRedirect(t *testing.T) {
parent: oidc.ErrInteractionRequired().WithDescription("sign in"),
},
want: &Redirect{
URL: "http://example.com/callback?error=interaction_required&error_description=sign+in&state=state1",
Header: make(http.Header),
URL: "http://example.com/callback?error=interaction_required&error_description=sign+in&state=state1",
},
wantLog: `{
"level":"WARN",
Expand Down
8 changes: 6 additions & 2 deletions pkg/op/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ type Response struct {
// without custom headers.
func NewResponse(data any) *Response {
return &Response{
Data: data,
Header: make(http.Header),
Data: data,
}
}

Expand All @@ -242,7 +243,10 @@ type Redirect struct {
}

func NewRedirect(url string) *Redirect {
return &Redirect{URL: url}
return &Redirect{
Header: make(http.Header),
URL: url,
}
}

func (red *Redirect) writeOut(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 1e75773

Please sign in to comment.