diff options
author | Matthew Holt <[email protected]> | 2019-10-15 14:07:10 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-10-15 14:07:10 -0600 |
commit | abf5ab340ed76792214ae80c62df7abe0ad1b8a8 (patch) | |
tree | f0cedd8a36fb03a2ad324c9398180aafb8bd462a /modules/caddyhttp/caddyhttp.go | |
parent | acf7dea68fe6ace110221faa26c2503a1ea432ce (diff) | |
download | caddy-abf5ab340ed76792214ae80c62df7abe0ad1b8a8.tar.gz caddy-abf5ab340ed76792214ae80c62df7abe0ad1b8a8.zip |
caddyhttp: Improve ResponseRecorder to buffer headers
Diffstat (limited to 'modules/caddyhttp/caddyhttp.go')
-rw-r--r-- | modules/caddyhttp/caddyhttp.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go index 5631b300b..29a5ab071 100644 --- a/modules/caddyhttp/caddyhttp.go +++ b/modules/caddyhttp/caddyhttp.go @@ -593,6 +593,19 @@ func (ws WeakString) String() string { return string(ws) } +// CopyHeader copies HTTP headers by completely +// replacing dest with src. (This allows deletions +// to be propagated, assuming src started as a +// consistent copy of dest.) +func CopyHeader(dest, src http.Header) { + for field := range dest { + delete(dest, field) + } + for field, val := range src { + dest[field] = val + } +} + // StatusCodeMatches returns true if a real HTTP status code matches // the configured status code, which may be either a real HTTP status // code or an integer representing a class of codes (e.g. 4 for all |