utils

package
v0.0.0-...-f6b2f6e Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStreamTooLarge = errors.New("read too many bytes")

Functions

func RewriteProxyURL

func RewriteProxyURL(origin, proxy *url.URL) (*url.URL, error)

RewriteProxyURL replaces the base part of origin (everything up to the path) with the proxy URL. The query paremeters from proxy are copied. If proxy is nil, then origin is returned as is.

Types

type ReadCounter

type ReadCounter interface {
	io.Reader
	Count() int64
}

func CountReads

func CountReads(r io.Reader) ReadCounter

func ReadAtMost

func ReadAtMost(r io.Reader, size int64) ReadCounter

ReadAtMost, like ReadExactly, returns a reader that expects to read at most size bytes.

func ReadExactly

func ReadExactly(r io.Reader, size int64) ReadCounter

ReadExactly returns a reader that expects to read exactly size number of bytes. If io.EOF is returned before reading size bytes, the error is replaced by io.ErrUnexpectedEOF. Similarly if, the reader reads past size bytes, the reader replaces the error with ErrStreamTooLarge.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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