httpbuffer

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: ISC Imports: 7 Imported by: 0

README

httpbuffer

-- import "vimagination.zapto.org/httpbuffer"

Package httpbuffer provides a buffer for HTTP requests so that the Content-Length may be set and compression applied for dynamic pages.

Usage

var (
	// BufferSize determines the initial size of the buffer
	BufferSize = 128 << 10
)
func Register
func Register(e Encoding)

Register registers the encoding for the buffers to use. Should not be used passed initialisation.

type Encoding
type Encoding interface {
	// Open takes a buffer and returns an encoder-wrapped buffer
	Open(io.Writer) io.Writer

	// Close returns the encoder-wrapped buffer to flush/close and release
	// resources
	Close(io.Writer)

	// Name returns the identifier for the encoding algorithm
	Name() string
}

Encoding represents a type that applies a Coding to a byte stream

type Handler
type Handler struct {
	http.Handler
}

Handler wraps a http.Handler and provides a buffer and possible gzip compression. It buffers the Writes and sends the Content-Length header before Writing the buffer to the client.

func (Handler) ServeHTTP
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface

Documentation

Overview

Package httpbuffer provides a buffer for HTTP requests so that the Content-Length may be set and compression applied for dynamic pages.

Index

Constants

This section is empty.

Variables

View Source
var (
	// BufferSize determines the initial size of the buffer
	BufferSize = 128 << 10
)

Functions

func Register

func Register(e Encoding)

Register registers the encoding for the buffers to use. Should not be used passed initialisation.

Types

type Encoding

type Encoding interface {
	// Open takes a buffer and returns an encoder-wrapped buffer
	Open(io.Writer) io.Writer

	// Close returns the encoder-wrapped buffer to flush/close and release
	// resources
	Close(io.Writer)

	// Name returns the identifier for the encoding algorithm
	Name() string
}

Encoding represents a type that applies a Coding to a byte stream

type Handler

type Handler struct {
	http.Handler
}

Handler wraps a http.Handler and provides a buffer and possible gzip compression. It buffers the Writes and sends the Content-Length header before Writing the buffer to the client.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface

Directories

Path Synopsis
Package brotli provides an Encoder for the httpbuffer package that uses brotli compression.
Package brotli provides an Encoder for the httpbuffer package that uses brotli compression.
Package deflate provides an Encoder for the httpbuffer package that uses deflate compression
Package deflate provides an Encoder for the httpbuffer package that uses deflate compression
Package gzip provides an Encoder for the httpbuffer package that uses gzip compression.
Package gzip provides an Encoder for the httpbuffer package that uses gzip compression.

Jump to

Keyboard shortcuts

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