| 148 | } |
| 149 | |
| 150 | func dumpRequestHeaders(req *http.Request, httpHeadersToExclude map[string]bool) ([]byte, error) { |
| 151 | var b bytes.Buffer |
| 152 | |
| 153 | // In case users initialize the Log middleware using the exported struct, skip the default headers anyway |
| 154 | if len(httpHeadersToExclude) == 0 { |
| 155 | httpHeadersToExclude = AlwaysExcludedHeaders |
| 156 | } |
| 157 | // Exclude some headers for security, or just that we don't need them when debugging |
| 158 | err := req.Header.WriteSubset(&b, httpHeadersToExclude) |
| 159 | if err != nil { |
| 160 | return nil, err |
| 161 | } |
| 162 | |
| 163 | ret := bytes.ReplaceAll(b.Bytes(), []byte("\r\n"), []byte("; ")) |
| 164 | return ret, nil |
| 165 | } |