package protocol

import (
	

	
)
ValidateEndpointHostHandler is a request handler that will validate the request endpoint's hosts is a valid RFC 3986 host.
var ValidateEndpointHostHandler = request.NamedHandler{
	Name: "awssdk.protocol.ValidateEndpointHostHandler",
	Fn: func( *request.Request) {
		 := ValidateEndpointHost(.Operation.Name, .HTTPRequest.URL.Host)
		if  != nil {
			.Error = 
		}
	},
}
ValidateEndpointHost validates that the host string passed in is a valid RFC 3986 host. Returns error if the host is not valid.
func (,  string) error {
	 := request.ErrInvalidParams{Context: }
	 := strings.Split(, ".")

	for ,  := range  {
Allow trailing dot for FQDN hosts.
			continue
		}

		if !ValidHostLabel() {
			.Add(request.NewErrParamFormat(
				"endpoint host label", "[a-zA-Z0-9-]{1,63}", ))
		}
	}

	if len() > 255 {
		.Add(request.NewErrParamMaxLen(
			"endpoint host", 255, ,
		))
	}

	if .Len() > 0 {
		return 
	}
	return nil
}
ValidHostLabel returns if the label is a valid RFC 3986 host label.
func ( string) bool {
	if  := len();  == 0 ||  > 63 {
		return false
	}
	for ,  := range  {
		switch {
		case  >= '0' &&  <= '9':
		case  >= 'A' &&  <= 'Z':
		case  >= 'a' &&  <= 'z':
		case  == '-':
		default:
			return false
		}
	}

	return true