summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/caddyhttp.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-10-15 14:07:10 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-10-15 14:07:10 -0600
commitabf5ab340ed76792214ae80c62df7abe0ad1b8a8 (patch)
treef0cedd8a36fb03a2ad324c9398180aafb8bd462a /modules/caddyhttp/caddyhttp.go
parentacf7dea68fe6ace110221faa26c2503a1ea432ce (diff)
caddyhttp: Improve ResponseRecorder to buffer headers
Diffstat (limited to 'modules/caddyhttp/caddyhttp.go')
-rw-r--r--modules/caddyhttp/caddyhttp.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go
index 5631b30..29a5ab0 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