httpurl

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package httpurl contains validation shared by HTTP URL construction boundaries. It deliberately does not decide whether a particular caller may use plaintext; production-mode policy remains at the application boundary.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingHost reports an HTTP authority with no host component.
	ErrMissingHost = errors.New("must have a host")

	// ErrInvalidHostname reports an authority such as :443 or . that has a
	// syntactic Host value but no usable destination hostname.
	ErrInvalidHostname = errors.New("must have a non-empty, non-dot hostname")

	// ErrInvalidPort reports an explicitly configured TCP port outside the
	// usable 1..65535 range (including an empty explicit port).
	ErrInvalidPort = errors.New("explicit port must be between 1 and 65535")
)

Functions

func NormalizeOrigin

func NormalizeOrigin(raw string) (string, error)

NormalizeOrigin validates raw as an HTTP(S) origin and returns its one canonical spelling. A single trailing slash is accepted and removed. Empty query and fragment markers are rejected rather than silently discarded, so configuration and direct client construction enforce the same boundary.

func ValidateAuthority

func ValidateAuthority(parsed *url.URL) error

ValidateAuthority proves that parsed has a usable HTTP destination authority. url.Parse rejects malformed and non-numeric ports, but it accepts port-only hosts (":443"), empty explicit ports, port zero, and values above 65535. Leaving those until transport time can turn a durable side effect into an indefinitely undeliverable request; a port-only host can also resolve to a local/unspecified destination.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL