// One time, do the conversion from our the public facing Configuration,
// to all the formats we use internally strings for headers.. slices for looping
187693
func (config *Config) prepare() {
	config.origins = strings.Split(config.Origins, ", ")
	config.methods = strings.Split(config.Methods, ", ")
	config.requestHeaders = strings.Split(config.RequestHeaders, ", ")
	config.maxAge = fmt.Sprintf("%.f", config.MaxAge.Seconds())

	// Generates a boolean of value "true".
	config.credentials = fmt.Sprintf("%t", config.Credentials)

	// Convert to lower-case once as request headers are supposed to be a case-insensitive match
	for idx, header := range config.requestHeaders {
		config.requestHeaders[idx] = strings.ToLower(header)
	}
}
198367
func HyperHeaderRelations(header http.Header, rels Relations) Relations {
	if rels == nil {
		rels = make(Relations)
	}

	link := header.Get("Link")
	if len(link) == 0 {
		return rels
	}

	for _, l := range strings.Split(link, ",") {
		l = strings.TrimSpace(l)
		segments := strings.Split(l, ";")

		if len(segments) < 2 {
			continue
		}

		if !strings.HasPrefix(segments[0], "<") || !strings.HasSuffix(segments[0], ">") {
			continue
		}

		url, err := url.Parse(segments[0][1 : len(segments[0])-1])
		if err != nil {
			continue
		}

		link := Hyperlink(url.String())

		for _, segment := range segments[1:] {
			switch strings.TrimSpace(segment) {
			case `rel="next"`:
				rels["next"] = link
			case `rel="prev"`:
				rels["prev"] = link
			case `rel="first"`:
				rels["first"] = link
			case `rel="last"`:
				rels["last"] = link
			}
		}
	}

	return rels
}
40214
func Convert_v1_TemplateServiceBrokerConfig_To_config_TemplateServiceBrokerConfig(in *TemplateServiceBrokerConfig, out *config.TemplateServiceBrokerConfig, s conversion.Scope) error {
	return autoConvert_v1_TemplateServiceBrokerConfig_To_config_TemplateServiceBrokerConfig(in, out, s)
}
921373
func SetResponseHeaderValues(resp *http.Response, h string, values []string) {
	if resp.Header == nil {
		resp.Header = make(http.Header)
	}
	for _, v := range values {
		resp.Header.Add(h, v)
	}
}
784878
func Convert_config_ProviderConfiguration_To_v1_ProviderConfiguration(in *config.ProviderConfiguration, out *ProviderConfiguration, s conversion.Scope) error {
	return autoConvert_config_ProviderConfiguration_To_v1_ProviderConfiguration(in, out, s)
}
1143552
func Convert_config_StringSource_To_v1_StringSource(in *config.StringSource, out *v1.StringSource, s conversion.Scope) error {
	return autoConvert_config_StringSource_To_v1_StringSource(in, out, s)
}
1305399
func ToInterfaceSlice(slice interface{}) []interface{} {
	v := reflect.ValueOf(slice)
	is := make([]interface{}, 0)
	if v.Kind() == reflect.Slice {
		is = make([]interface{},0 ,v.Len())
		for i := 0; i < v.Len(); i++ {
			is = append(is, v.Index(i).Interface())
		}
	}
	return is
}
208743
func Convert_v1_EncryptionConfiguration_To_config_EncryptionConfiguration(in *EncryptionConfiguration, out *config.EncryptionConfiguration, s conversion.Scope) error {
	return autoConvert_v1_EncryptionConfiguration_To_config_EncryptionConfiguration(in, out, s)
}
1324669
func decodeSettings(headerVal string) ([]http2.Setting, error) {
	b, err := base64.RawURLEncoding.DecodeString(headerVal)
	if err != nil {
		return nil, err
	}
	if len(b)%6 != 0 {
		return nil, err
	}
	settings := make([]http2.Setting, 0)
	for i := 0; i < len(b)/6; i++ {
		settings = append(settings, http2.Setting{
			ID:  http2.SettingID(binary.BigEndian.Uint16(b[i*6 : i*6+2])),
			Val: binary.BigEndian.Uint32(b[i*6+2 : i*6+6]),
		})
	}

	return settings, nil
}
694300
func transformSubProtocolHeader(header string) string {
	tokens := strings.SplitN(header, "Bearer,", 2)

	if len(tokens) < 2 {
		return ""
	}

	return fmt.Sprintf("Bearer %v", strings.Trim(tokens[1], " "))
}
255485
func (mh *MethodHandler) Headers(headerNames ...string) *MethodHandler {
	if mh.headers == nil {
		mh.headers = make([]string, 0)
	}
	mh.headers = append(mh.headers, headerNames...)
	return mh
}
38383
func headersToSlice(header http.Header) []interface{} {
	res := make([]interface{}, 2*len(header))
	i := 0
	for k, v := range header {
		res[i] = k
		if len(v) == 1 {
			res[i+1] = v[0]
		} else {
			res[i+1] = v
		}
		i += 2
	}
	return res
}
434151
func Convert_Slice_string_To_v1_Time(input *[]string, out *Time, s conversion.Scope) error {
	str := ""
	if len(*input) > 0 {
		str = (*input)[0]
	}
	return out.UnmarshalQueryParameter(str)
}
923051
func versionSegments(segments string) []int {
	segments = strings.Trim(segments, "v")
	segments = strings.Split(segments, "-")[0]
	s := strings.Split(segments, ".")
	segmentSlice := make([]int, len(s))
	for i, v := range s {
		segmentSlice[i], _ = strconv.Atoi(v)
	}
	return segmentSlice
}
217856
func CloneHeader(in http.Header) http.Header {
	out := make(http.Header, len(in))
	for key, values := range in {
		newValues := make([]string, len(values))
		copy(newValues, values)
		out[key] = newValues
	}
	return out
}
109422
func ConvertSpaceTemplates(appl application.Application, request *http.Request, spaceTemplates []spacetemplate.SpaceTemplate, additional ...SpaceTemplateConvertFunc) []*app.SpaceTemplate {
	var is = []*app.SpaceTemplate{}
	for _, i := range spaceTemplates {
		is = append(is, ConvertSpaceTemplate(appl, request, i, additional...))
	}
	return is
}
1368964
func Convert_v1_TemplateInstanceSpec_To_template_TemplateInstanceSpec(in *v1.TemplateInstanceSpec, out *template.TemplateInstanceSpec, s conversion.Scope) error {
	return autoConvert_v1_TemplateInstanceSpec_To_template_TemplateInstanceSpec(in, out, s)
}