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 ¶
const (
DefaultMaxContentLength = 4194304 // 4 MiB
)
The default value(s) used by Config.
Variables ¶
var HTTPStatusOK = HTTPStatusCode(http.StatusOK)
HTTPStatusOK ensures the response to have the status code 200 (OK).
Functions ¶
func CheckPrerequisites ¶
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 ¶
HTTPStatusCode ensures the response to have one of the provided HTTP status codes. Its Process method returns an HTTPStatusError on error.
func MaxContentLength ¶
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.