Help us shape the future of Go! Take the 2026 Go Developer Survey

header

package
v1.59.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Overview

Package header can be used to sanitize HTTP request and response headers.

Index

Constants

This section is empty.

Variables

View Source
var DefaultSanitizers = map[string]SanitizeHeaderFunc{
	"Authorization":       AuthorizationSanitizer,
	"Set-Cookie":          SetCookieSanitizer,
	"Cookie":              CookieSanitizer,
	"Proxy-Authorization": AuthorizationSanitizer,
}

DefaultSanitizers contains a list of sanitizers to be used for common headers.

Functions

func AuthorizationSanitizer

func AuthorizationSanitizer(unsafe string) string

AuthorizationSanitizer is used to sanitize Authorization and Proxy-Authorization headers.

func CookieSanitizer

func CookieSanitizer(unsafe string) string

CookieSanitizer is used to sanitize Cookie header.

func Sanitize

func Sanitize(sanitizers map[string]SanitizeHeaderFunc, headers http.Header) http.Header

Sanitize list of headers. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ can be consulted for header syntax.

func SetCookieSanitizer

func SetCookieSanitizer(unsafe string) string

SetCookieSanitizer is used to sanitize Set-Cookie header.

Types

type SanitizeHeaderFunc

type SanitizeHeaderFunc func(string) string

SanitizeHeaderFunc implements sanitization for a header value.

Jump to

Keyboard shortcuts

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