helpers

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EventStreamBytes = []byte("text/event-stream")
)
View Source
var HopHeaders = []string{
	"Connection",
	"Upgrade",
	"Proxy-Connection",
	"Keep-Alive",
	"Proxy-Authenticate",
	"Proxy-Authorization",
	"Te",
	"Trailer",
	"Transfer-Encoding",
	"Server",
}

Functions

func BytesToString

func BytesToString(b []byte) string

func DeleteFastHTTPRequestHopHeaders

func DeleteFastHTTPRequestHopHeaders(req *fasthttp.Request)

func DeleteFastHTTPResponseHopHeaders

func DeleteFastHTTPResponseHopHeaders(res *fasthttp.Response)

func DeleteHopHeaders

func DeleteHopHeaders(h http.Header)

DeleteHopHeaders deletes the given headers from the given request.

func FastHTTPHasHeaderValue

func FastHTTPHasHeaderValue(s, value []byte) bool

func FastHTTPHijackHandler

func FastHTTPHijackHandler(bufferedEgress *BufferedReadWriteCloser, buffer *bufio.Reader) func(net.Conn)

func FastHTTPRequestUpgradeType

func FastHTTPRequestUpgradeType(req *fasthttp.Request) string

func FastHTTPResponseUpgradeType

func FastHTTPResponseUpgradeType(res *fasthttp.Response) string

func FastHTTPUpgradeCopier

func FastHTTPUpgradeCopier(ctx *fasthttp.RequestCtx, reqUpType string, bufferedEgress *BufferedReadWriteCloser, buffer *bufio.Reader, uri *fasthttp.URI, addr string, logger *zerolog.Logger)

func FastHTTPUpgradeRespond

func FastHTTPUpgradeRespond(ctx *fasthttp.RequestCtx, reqUpType string, bufferedEgress *BufferedReadWriteCloser, buffer *bufio.Reader, uri *fasthttp.URI, addr string, logger *zerolog.Logger)

func Respond

func Respond(w http.ResponseWriter, req *http.Request, res *http.Response)

Respond responds to the given request using the given response and the http.ResponseWriter.

It deletes Hop Headers, and handles streaming responses.

func UpgradeType

func UpgradeType(h http.Header) string

UpgradeType returns the upgrade type (if any) for the given headers.

Types

type BufferedReadWriteCloser

type BufferedReadWriteCloser struct {
	io.WriteCloser
	// contains filtered or unexported fields
}

func NewBufferedReadWriteCloser

func NewBufferedReadWriteCloser(rwc io.ReadWriteCloser) *BufferedReadWriteCloser

func (*BufferedReadWriteCloser) Buffer

func (b *BufferedReadWriteCloser) Buffer() *bufio.Reader

func (*BufferedReadWriteCloser) Close

func (b *BufferedReadWriteCloser) Close() error

func (*BufferedReadWriteCloser) Read

func (b *BufferedReadWriteCloser) Read(p []byte) (n int, err error)

type Flusher

type Flusher struct {
	// contains filtered or unexported fields
}

Flusher is a wrapper around an io.Writer that also implements the http.Flusher interface (encapsulated by the f interface) and its Write method calls the underlying Flush method after every write.

func NewFlusher

func NewFlusher(w http.ResponseWriter) (*Flusher, bool)

NewFlusher returns a new flusher that wraps the given http.ResponseWriter.

func (*Flusher) Write

func (f *Flusher) Write(p []byte) (n int, err error)

Write calls the underlying Flush method after every write.

Jump to

Keyboard shortcuts

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