httputil

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0, MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DateHeaderTimestampFormat - Last-Modified: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
	DateHeaderTimestampFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
)

Variables

View Source
var ErrBadRange = errors.New("invalid range")
View Source
var ErrUnsatisfiableRange = errors.New("unsatisfiable range")

Functions

func ETag

func ETag(checksum string) string

func ExtensionsByType

func ExtensionsByType(fileName string) string

func HeaderTimestamp

func HeaderTimestamp(ts time.Time) string

func HostMatches

func HostMatches(r *http.Request, hosts []string) bool

func HostOnly

func HostOnly(hostname string) string

func HostSubdomainOf

func HostSubdomainOf(r *http.Request, hosts []string) bool

func HostsOnly

func HostsOnly(hostname []string) []string

func IsRequestCanceled

func IsRequestCanceled(r *http.Request) bool

func IsSuccessStatusCode

func IsSuccessStatusCode(response *http.Response) bool

IsSuccessStatusCode returns true for status code 2xx

func RequestScheme

func RequestScheme(r *http.Request) string

func ServeHealth

func ServeHealth() http.Handler

func ServePPROF

func ServePPROF(pprofPrefix string) http.Handler

func SetHealthHandlerInfo

func SetHealthHandlerInfo(info string)

Types

type MetricResponseWriter

type MetricResponseWriter struct {
	http.ResponseWriter
	StatusCode int
}

func NewMetricResponseWriter

func NewMetricResponseWriter(w http.ResponseWriter) *MetricResponseWriter

func (*MetricResponseWriter) WriteHeader

func (mrw *MetricResponseWriter) WriteHeader(code int)

type Range

type Range struct {
	StartOffset int64
	EndOffset   int64
}

Range represents an RFC 2616 HTTP Range

func ParseRange

func ParseRange(spec string, length int64) (Range, error)

ParseRange parses an HTTP RFC 2616 Range header value and returns an Range object for the given object length

func (Range) Size

func (r Range) Size() int64

func (Range) String

func (r Range) String() string

Jump to

Keyboard shortcuts

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