Skip to content

Commit

Permalink
Merge pull request #6 from infiniteloopcloud/fix-silent-proxy-content…
Browse files Browse the repository at this point in the history
…-type-setup

Fix silent proxy content type default value
  • Loading branch information
PumpkinSeed authored Aug 12, 2024
2 parents 7abc39d + 2088374 commit 604da9d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ func Request(ctx context.Context, respStruct interface{}, opts RequestOpts) (*ht
}

func SilentProxy(ctx context.Context, w http.ResponseWriter, resp *http.Response) {
w.Header().Set("Content-Type", "application/json")

for key, valueSlice := range resp.Header {
for _, v := range valueSlice {
w.Header().Add(key, v)
}
}

if w.Header().Get("Content-Type") == "" {
w.Header().Set("Content-Type", "application/json")
}

w.WriteHeader(resp.StatusCode)

if resp.Body == nil {
Expand Down

0 comments on commit 604da9d

Please sign in to comment.