preverify

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package preverify implements processors to verify that HTTP responses can be distributed as signed exchanges. These processors do not mutate the provided exchange.Response: they just inspect it and report an error when it does not meet the criteria.

Index

Constants

View Source
const (
	DefaultMaxContentLength = 4194304 // 4 MiB
)

The default value(s) used by Config.

Variables

View Source
var HTTPStatusOK = HTTPStatusCode(http.StatusOK)

HTTPStatusOK ensures the response to have the status code 200 (OK).

Functions

func CheckPrerequisites

func CheckPrerequisites(config Config) processor.Processor

CheckPrerequisites returns a Processor to verify the provided response meets all prerequisites as specified in config.

CheckPrerequisites is usually used indirectly, through the complexproc package.

func HTTPStatusCode

func HTTPStatusCode(expectedCodes ...int) processor.Processor

HTTPStatusCode ensures the response to have one of the provided HTTP status codes. Its Process method returns an HTTPStatusError on error.

func MaxContentLength

func MaxContentLength(limit int) processor.Processor

MaxContentLength requires the content (the response body) to be not larger then limit.

Types

type Config

type Config struct {
	// GoodStatusCodes specifies the set of HTTP response codes to consider
	// to be eligible for signed exchanges.
	//
	// nil or empty implies []int{http.StatusOK}, which is considered to be
	// the current best practice.
	GoodStatusCodes []int

	// MaxContentLength specifies the maximum size of each resource turned
	// into a signed exchange, in bytes.
	//
	// Zero implies DefaultMaxContentLength; a negative implies "unlimited."
	MaxContentLength int
}

Config holds the parameters to CheckPrerequisites.

type HTTPStatusError

type HTTPStatusError struct {
	// StatusCode represents the HTTP status code returned.
	StatusCode int
}

HTTPStatusError represents an HTTP status error.

func NewHTTPStatusError

func NewHTTPStatusError(statusCode int) *HTTPStatusError

NewHTTPStatusError creates a new HTTPStatusError.

func (*HTTPStatusError) Error

func (e *HTTPStatusError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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