Ejemplo n.º 1
0
// Copy returns a deep copy of the HeadersRewrite
func (h HeadersRewrite) Copy() HeadersRewrite {
	return HeadersRewrite{
		RemoveHeaders: utils.CopyStringSlice(h.RemoveHeaders),
		AddHeaders:    h.AddHeaders.Copy(),
		SetHeaders:    h.SetHeaders.Copy(),
	}
}
Ejemplo n.º 2
0
// Copy makes a deep copy of the HeaderPairs
func (h HeaderPairs) Copy() HeaderPairs {
	var res = make(HeaderPairs)
	for key, value := range h {
		res[key] = utils.CopyStringSlice(value)
	}
	return res
}
Ejemplo n.º 3
0
// CopyHeadersWithout copies headers from `from` to `to` except for the `exceptions`
func CopyHeadersWithout(from, to http.Header, exceptions ...string) {
	for k := range from {
		shouldCopy := true
		for _, e := range exceptions {
			if e == k {
				shouldCopy = false
				break
			}
		}
		if shouldCopy {
			to[k] = utils.CopyStringSlice(from[k])
		}
	}
}
Ejemplo n.º 4
0
// CopyHeaders copies all headers from `from` to `to`.
func CopyHeaders(from, to http.Header) {
	for k := range from {
		to[k] = utils.CopyStringSlice(from[k])
	}
}