header

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: 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