Skip to content

Commit

Permalink
feat(header): check empty headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jindrichskupa committed Apr 10, 2024
1 parent 1d7e586 commit 1c9513e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ func (p *logRequest) ServeHTTP(w http.ResponseWriter, r *http.Request) {

headers := make(map[string]string)
for name, values := range r.Header {
headers[name] = values[0] // Take the first value of the header
if len(values) > 0 {
headers[name] = values[0] // Take the first value of the header
}
}

reqData := requestData{
Expand All @@ -137,7 +139,9 @@ func (p *logRequest) ServeHTTP(w http.ResponseWriter, r *http.Request) {

respHeaders := make(map[string]string)
for name, values := range resp.Header() {
respHeaders[name] = values[0] // Take the first value of the header
if len(values) > 0 {
respHeaders[name] = values[0] // Take the first value of the header
}
}

resData := responseData{
Expand Down

0 comments on commit 1c9513e

Please sign in to comment.