func (l *HandlerList) SetFrontNamed(n NamedHandler) {
	if !l.SwapNamed(n) {
		l.PushFrontNamed(n)
	}
}
SetFrontNamed will replace the named handler if it exists in the handler list.
If the handler does not exist the handler will be added to the beginning of
the list.
package request
import (
	"fmt"
	"strings"
)
type Handlers struct {
	Validate         HandlerList
	Build            HandlerList
	BuildStream      HandlerList
	Sign             HandlerList
	Send             HandlerList
	ValidateResponse HandlerList
	Unmarshal        HandlerList
	UnmarshalStream  HandlerList
	UnmarshalMeta    HandlerList
	UnmarshalError   HandlerList
	Retry            HandlerList
	AfterRetry       HandlerList
	CompleteAttempt  HandlerList
	Complete         HandlerList
}
func (h *Handlers) Copy() Handlers {
	return Handlers{
		Validate:         h.Validate.copy(),
		Build:            h.Build.copy(),
		BuildStream:      h.BuildStream.copy(),
		Sign:             h.Sign.copy(),
		Send:             h.Send.copy(),
		ValidateResponse: h.ValidateResponse.copy(),
		Unmarshal:        h.Unmarshal.copy(),
		UnmarshalStream:  h.UnmarshalStream.copy(),
		UnmarshalError:   h.UnmarshalError.copy(),
		UnmarshalMeta:    h.UnmarshalMeta.copy(),
		Retry:            h.Retry.copy(),
		AfterRetry:       h.AfterRetry.copy(),
		CompleteAttempt:  h.CompleteAttempt.copy(),
		Complete:         h.Complete.copy(),
	}
}
func (h *Handlers) Clear() {
	h.Validate.Clear()
	h.Build.Clear()
	h.BuildStream.Clear()
	h.Send.Clear()
	h.Sign.Clear()
	h.Unmarshal.Clear()
	h.UnmarshalStream.Clear()
	h.UnmarshalMeta.Clear()
	h.UnmarshalError.Clear()
	h.ValidateResponse.Clear()
	h.Retry.Clear()
	h.AfterRetry.Clear()
	h.CompleteAttempt.Clear()
	h.Complete.Clear()
}
func (h *Handlers) IsEmpty() bool {
	if h.Validate.Len() != 0 {
		return false
	}
	if h.Build.Len() != 0 {
		return false
	}
	if h.BuildStream.Len() != 0 {
		return false
	}
	if h.Send.Len() != 0 {
		return false
	}
	if h.Sign.Len() != 0 {
		return false
	}
	if h.Unmarshal.Len() != 0 {
		return false
	}
	if h.UnmarshalStream.Len() != 0 {
		return false
	}
	if h.UnmarshalMeta.Len() != 0 {
		return false
	}
	if h.UnmarshalError.Len() != 0 {
		return false
	}
	if h.ValidateResponse.Len() != 0 {
		return false
	}
	if h.Retry.Len() != 0 {
		return false
	}
	if h.AfterRetry.Len() != 0 {
		return false
	}
	if h.CompleteAttempt.Len() != 0 {
		return false
	}
	if h.Complete.Len() != 0 {
		return false
	}
	return true
}
type HandlerListRunItem struct {
	Index   int
	Handler NamedHandler
	Request *Request
}
type HandlerList struct {
	list []NamedHandler
	AfterEachFn func(item HandlerListRunItem) bool
}
type NamedHandler struct {
	Name string
	Fn   func(*Request)
}
func (l *HandlerList) copy() HandlerList {
	n := HandlerList{
		AfterEachFn: l.AfterEachFn,
	}
	if len(l.list) == 0 {
		return n
	}
	n.list = append(make([]NamedHandler, 0, len(l.list)), l.list...)
	return n
}
func (l *HandlerList) Clear() {
	l.list = l.list[0:0]
}
func (l *HandlerList) Len() int {
	return len(l.list)
}
func (l *HandlerList) PushBack(f func(*Request)) {
	l.PushBackNamed(NamedHandler{"__anonymous", f})
}
func (l *HandlerList) PushBackNamed(n NamedHandler) {
	if cap(l.list) == 0 {
		l.list = make([]NamedHandler, 0, 5)
	}
	l.list = append(l.list, n)
}
func (l *HandlerList) PushFront(f func(*Request)) {
	l.PushFrontNamed(NamedHandler{"__anonymous", f})
}
func (l *HandlerList) PushFrontNamed(n NamedHandler) {
	if cap(l.list) == len(l.list) {
		l.list = append([]NamedHandler{n}, l.list...)
	} else {
		l.list = append(l.list, NamedHandler{})
		copy(l.list[1:], l.list)
		l.list[0] = n
	}
}
func (l *HandlerList) Remove(n NamedHandler) {
	l.RemoveByName(n.Name)
}
func (l *HandlerList) RemoveByName(name string) {
	for i := 0; i < len(l.list); i++ {
		m := l.list[i]
		if m.Name == name {
			copy(l.list[i:], l.list[i+1:])
			l.list[len(l.list)-1] = NamedHandler{}
			l.list = l.list[:len(l.list)-1]
			i--
		}
	}
}
func (l *HandlerList) SwapNamed(n NamedHandler) (swapped bool) {
	for i := 0; i < len(l.list); i++ {
		if l.list[i].Name == n.Name {
			l.list[i].Fn = n.Fn
			swapped = true
		}
	}
	return swapped
}
func (l *HandlerList) Swap(name string, replace NamedHandler) bool {
	var swapped bool
	for i := 0; i < len(l.list); i++ {
		if l.list[i].Name == name {
			l.list[i] = replace
			swapped = true
		}
	}
	return swapped
}
func (l *HandlerList) SetBackNamed(n NamedHandler) {
	if !l.SwapNamed(n) {
		l.PushBackNamed(n)
	}
}