/*
	Common Header Validation.
*/
510643
func checkHeaders(h Headers, p string) error {
	if h == nil {
		return EHDRNIL
	}
	// Length check
	if e := h.Validate(); e != nil {
		return e
	}
	// Empty key / value check
	for i := 0; i < len(h); i += 2 {
		if h[i] == "" {
			return EHDRMTK
		}
		if p == SPL_10 && h[i+1] == "" {
			return EHDRMTV
		}
	}
	// UTF8 check
	if p != SPL_10 {
		_, e := h.ValidateUTF8()
		if e != nil {
			return e
		}
	}
	return nil
}
1348352
func (m *CommonExtensionConfig) Validate() error {
	if m == nil {
		return nil
	}

	switch m.ConfigType.(type) {

	case *CommonExtensionConfig_AdminConfig:

		{
			tmp := m.GetAdminConfig()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return CommonExtensionConfigValidationError{
						field:  "AdminConfig",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *CommonExtensionConfig_StaticConfig:

		{
			tmp := m.GetStaticConfig()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return CommonExtensionConfigValidationError{
						field:  "StaticConfig",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	default:
		return CommonExtensionConfigValidationError{
			field:  "ConfigType",
			reason: "value is required",
		}

	}

	return nil
}
969734
func (r *httpVPackResponse) Header(key string) string {
	return r.resp.Header.Get(key)
}
958952
func (c *GetConfigByHashCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}
1013833
func (self *simplePBundle) Header(s string) (string, bool) {
	v, ok := self.h[strings.ToLower(s)]
	return v, ok
}
306807
func (ch *ChunkHeader) Validate() error {
	if string(ch.Magic[:]) != ChunkMagic {
		return fmt.Errorf("Invalid chunk magic: %q", ch.Magic)
	}
	if ch.SizeHeader != 128 {
		return fmt.Errorf("Invalid chunk header size: %d instead of 128", ch.SizeHeader)
	}
	if ch.OffsetLastRec >= ChunkSize {
		return fmt.Errorf("Last event offset exceed size of chunk")
	}
	return nil
}
404738
func (m *HeaderFilter) Validate() error {
	if m == nil {
		return nil
	}

	if m.GetHeader() == nil {
		return HeaderFilterValidationError{
			field:  "Header",
			reason: "value is required",
		}
	}

	{
		tmp := m.GetHeader()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return HeaderFilterValidationError{
					field:  "Header",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	return nil
}
92868
func checkValidMD5(h http.Header) ([]byte, error) {
	md5B64, ok := h["Content-Md5"]
	if ok {
		if md5B64[0] == "" {
			return nil, fmt.Errorf("Content-Md5 header set to empty value")
		}
		return base64.StdEncoding.DecodeString(md5B64[0])
	}
	return []byte{}, nil
}
843061
func (m *HttpGrpcAccessLogConfig) Validate() error {
	if m == nil {
		return nil
	}

	if m.GetCommonConfig() == nil {
		return HttpGrpcAccessLogConfigValidationError{
			field:  "CommonConfig",
			reason: "value is required",
		}
	}

	{
		tmp := m.GetCommonConfig()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return HttpGrpcAccessLogConfigValidationError{
					field:  "CommonConfig",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	return nil
}
373408
func (c *ContivClient) addCustomRequestHeader(name, value string) {

	// lowercase the header name so we can easily check for duplicates in other places.
	// there can legitimately be many headers with the same name, but in some cases
	// (e.g., auth token) we want to enforce that there is only one.
	// Go internally canonicalizes them when we call Header.Add() anyways.
	name = strings.ToLower(name)

	c.customRequestHeaders = append(c.customRequestHeaders, [2]string{name, value})
}
517277
func (c *Context) Header(name string) string {
	return c.request.Header.Get(name)
}
1309193
func (c *Call) Header(k string) string {
	return (*encoding.Call)(c).Header(k)
}
1020628
func (c *GroupUpdateCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}
1320931
func (m *middleware) validateHeader(r *http.Request, auth string) (context.Context, *Error) {
	var f = strings.Fields(auth)
	if len(f) != 2 {
		return nil, ErrBadAuthorizationHeader
	}

	var scheme = strings.ToLower(f[0])
	var token = f[1]

	switch scheme {
	case schemeBasic:
		return m.validateBasicAuth(r)
	case schemeBearer:
		return m.validateJWT(r, token)
	default:
		return nil, ErrUnsupportedAuthScheme
	}
}
606738
func (m *Cluster_CommonLbConfig) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetHealthyPanicThreshold()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return Cluster_CommonLbConfigValidationError{
					field:  "HealthyPanicThreshold",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	{
		tmp := m.GetUpdateMergeWindow()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return Cluster_CommonLbConfigValidationError{
					field:  "UpdateMergeWindow",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	switch m.LocalityConfigSpecifier.(type) {

	case *Cluster_CommonLbConfig_ZoneAwareLbConfig_:

		{
			tmp := m.GetZoneAwareLbConfig()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return Cluster_CommonLbConfigValidationError{
						field:  "ZoneAwareLbConfig",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *Cluster_CommonLbConfig_LocalityWeightedLbConfig_:

		{
			tmp := m.GetLocalityWeightedLbConfig()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return Cluster_CommonLbConfigValidationError{
						field:  "LocalityWeightedLbConfig",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	return nil
}
1142790
func (c *GetConfigCall) Header() http.Header {
	if c.header_ == nil {
		c.header_ = make(http.Header)
	}
	return c.header_
}
643973
func ErrorHead(heading string, v ...interface{}) string {
	maxLen := 40
	subLen := len(heading)

	// print process, inserting a '-' (colon) 'n' times, where 'n' is the number
	// remaining after subtracting subLen (number of 'reserved' characters) from
	// maxLen (maximum number of allowed characters)
	return fmt.Sprintf("\n%s %s!!!\n", strings.Repeat(":", (maxLen-subLen)), strings.ToUpper(fmt.Sprintf(heading, v...)))
}