Categorygithub.com/VictoriaMetrics/fasthttp
modulepackage
1.2.0
Repository: https://github.com/victoriametrics/fasthttp.git
Documentation: pkg.go.dev

# README

Private copy of fasthttp for VictoriaMetrics usage.

It contains only the functionality required for VictoriaMetrics.

Do not use it in your own projects!

# Packages

Package fasthttputil provides utility functions for fasthttp.
Package reuseport provides TCP net.Listener with SO_REUSEPORT support.
Package stackless provides functionality that may save stack space for high number of concurrently running goroutines.

# Functions

AcquireArgs returns an empty Args object from the pool.
AcquireByteBuffer returns an empty byte buffer from the pool.
AcquireCookie returns an empty Cookie object from the pool.
AcquireRequest returns an empty Request instance from request pool.
AcquireResponse returns an empty Response instance from response pool.
AcquireURI returns an empty URI instance from the pool.
AppendBytesStr appends src to dst and returns the extended dst.
AppendDeflateBytes appends deflated src to dst and returns the resulting dst.
AppendDeflateBytesLevel appends deflated src to dst using the given compression level and returns the resulting dst.
AppendGunzipBytes appends gunzipped src to dst and returns the resulting dst.
AppendGzipBytes appends gzipped src to dst and returns the resulting dst.
AppendGzipBytesLevel appends gzipped src to dst using the given compression level and returns the resulting dst.
AppendHTMLEscape appends html-escaped s to dst and returns the extended dst.
AppendHTMLEscapeBytes appends html-escaped s to dst and returns the extended dst.
AppendHTTPDate appends HTTP-compliant (RFC1123) representation of date to dst and returns the extended dst.
AppendInflateBytes appends inflated src to dst and returns the resulting dst.
AppendIPv4 appends string representation of the given ip v4 to dst and returns the extended dst.
AppendNormalizedHeaderKey appends normalized header key (name) to dst and returns the resulting dst.
AppendNormalizedHeaderKeyBytes appends normalized header key (name) to dst and returns the resulting dst.
AppendQuotedArg appends url-encoded src to dst and returns appended dst.
AppendUint appends n to dst and returns the extended dst.
AppendUnquotedArg appends url-decoded src to dst and returns appended dst.
CompressHandler returns RequestHandler that transparently compresses response body generated by h if the request contains 'gzip' or 'deflate' 'Accept-Encoding' header.
CompressHandlerLevel returns RequestHandler that transparently compresses response body generated by h if the request contains 'gzip' or 'deflate' 'Accept-Encoding' header.
Dial dials the given TCP addr using tcp4.
DialDualStack dials the given TCP addr using both tcp4 and tcp6.
DialDualStackTimeout dials the given TCP addr using both tcp4 and tcp6 using the given timeout.
DialTimeout dials the given TCP addr using tcp4 using the given timeout.
Do performs the given http request and fills the given http response.
DoDeadline performs the given request and waits for response until the given deadline.
DoTimeout performs the given request and waits for response during the given timeout duration.
EqualBytesStr returns true if string(b) == s.
FileLastModified returns last modified time for the file.
FSHandler returns request handler serving static files from the given root folder.
Get appends url contents to dst and returns it as body.
GetDeadline appends url contents to dst and returns it as body.
GetTimeout appends url contents to dst and returns it as body.
ListenAndServe serves HTTP requests from the given TCP addr using the given handler.
ListenAndServeTLS serves HTTPS requests from the given TCP addr using the given handler.
ListenAndServeTLSEmbed serves HTTPS requests from the given TCP addr using the given handler.
ListenAndServeUNIX serves HTTP requests from the given UNIX addr using the given handler.
NewPathPrefixStripper returns path rewriter, which removes prefixSize bytes from the path prefix.
NewPathSlashesStripper returns path rewriter, which strips slashesCount leading slashes from the path.
NewStreamReader returns a reader, which replays all the data generated by sw.
NewVHostPathRewriter returns path rewriter, which strips slashesCount leading slashes from the path and prepends the path with request's host, thus simplifying virtual hosting for static files.
ParseByteRange parses 'Range: bytes=...' header value.
ParseHTTPDate parses HTTP-compliant (RFC1123) date.
ParseIPv4 parses ip address from ipStr into dst and returns the extended dst.
ParseUfloat parses unsigned float from buf.
ParseUint parses uint from buf.
Post
Post sends POST request to the given url with the given POST arguments.
ReleaseArgs returns the object acquired via AquireArgs to the pool.
ReleaseByteBuffer returns byte buffer to the pool.
ReleaseCookie returns the Cookie object acquired with AcquireCookie back to the pool.
ReleaseRequest returns req acquired via AcquireRequest to request pool.
ReleaseResponse return resp acquired via AcquireResponse to response pool.
ReleaseURI releases the URI acquired via AcquireURI.
SaveMultipartFile saves multipart file fh under the given filename path.
Serve serves incoming connections from the given listener using the given handler.
ServeConn serves HTTP requests from the given connection using the given handler.
ServeFile returns HTTP response containing compressed file contents from the given path.
ServeFileBytes returns HTTP response containing compressed file contents from the given path.
ServeFileBytesUncompressed returns HTTP response containing file contents from the given path.
ServeFileUncompressed returns HTTP response containing file contents from the given path.
ServeTLS serves HTTPS requests from the given net.Listener using the given handler.
ServeTLSEmbed serves HTTPS requests from the given net.Listener using the given handler.
StatusMessage returns HTTP status message for the given status code.
TimeoutHandler creates RequestHandler, which returns StatusRequestTimeout error with the given msg to the client if h didn't return during the given duration.
WriteDeflate writes deflated p to w and returns the number of compressed bytes written to w.
WriteDeflateLevel writes deflated p to w using the given compression level and returns the number of compressed bytes written to w.
WriteGunzip writes ungzipped p to w and returns the number of uncompressed bytes written to w.
WriteGzip writes gzipped p to w and returns the number of compressed bytes written to w.
WriteGzipLevel writes gzipped p to w using the given compression level and returns the number of compressed bytes written to w.
WriteInflate writes inflated p to w and returns the number of uncompressed bytes written to w.
WriteMultipartForm writes the given multipart form f with the given boundary to w.

# Constants

Supported compression levels.
Supported compression levels.
flate.DefaultCompression.
flate.HuffmanOnly.
Supported compression levels.
DefaultConcurrency is the maximum number of concurrent connections the Server may serve by default (i.e.
DefaultDialTimeout is timeout used by Dial and DialDualStack for establishing TCP connections.
DefaultDNSCacheDuration is the duration for caching resolved TCP addresses by Dial* functions.
DefaultLBClientTimeout is the default request timeout used by LBClient when calling LBClient.Do.
DefaultMaxConnsPerHost is the maximum number of concurrent connections http client may establish per host by default (i.e.
DefaultMaxIdleConnDuration is the default duration before idle keep-alive connection is closed.
DefaultMaxPendingRequests is the default value for PipelineClient.MaxPendingRequests.
DefaultMaxRequestBodySize is the maximum request body size the server reads by default.
FSCompressedFileSuffix is the suffix FS adds to the original file names when trying to store compressed file under the new file name.
FSHandlerCacheDuration is the default expiration duration for inactive file handlers opened by FS.
RFC 7231, 6.3.3.
RFC 5842, 7.1.
RFC 7231, 6.6.3.
RFC 7231, 6.5.1.
RFC 7231, 6.5.8.
RFC 7231, 6.2.1.
RFC 7231, 6.3.2.
RFC 7231, 6.5.14.
RFC 4918, 11.4.
RFC 7231, 6.5.3.
RFC 7231, 6.4.3.
RFC 7231, 6.6.5.
RFC 7231, 6.5.9.
RFC 7231, 6.6.6.
RFC 3229, 10.4.1.
RFC 4918, 11.5.
RFC 7231, 6.6.1.
RFC 7231, 6.5.10.
RFC 4918, 11.3.
RFC 5842, 7.2.
RFC 7231, 6.5.5.
RFC 7231, 6.4.2.
RFC 7231, 6.4.1.
RFC 4918, 11.1.
RFC 6585, 6.
RFC 7231, 6.3.5.
RFC 7231, 6.3.4.
RFC 7231, 6.5.6.
RFC 2774, 7.
RFC 7231, 6.5.4.
RFC 7231, 6.6.2.
RFC 7232, 4.1.
RFC 7231, 6.3.1.
RFC 7233, 4.1.
RFC 7231, 6.5.2.
RFC 7538, 3.
RFC 7232, 4.2.
RFC 6585, 3.
RFC 2518, 10.1.
RFC 7235, 3.2.
RFC 7233, 4.4.
RFC 7231, 6.5.11.
RFC 6585, 5.
RFC 7231, 6.5.7.
RFC 7231, 6.5.12.
RFC 7231, 6.3.6.
RFC 7231, 6.4.4.
RFC 7231, 6.6.4.
RFC 7231, 6.2.2.
RFC 7168, 2.3.3.
RFC 7231, 6.4.7.
RFC 6585, 4.
RFC 7235, 3.1.
RFC 7725, 3.
RFC 4918, 11.2.
RFC 7231, 6.5.13.
RFC 7231, 6.5.15.
RFC 7231, 6.4.5.
RFC 2295, 8.1.

# Variables

CookieExpireDelete may be set on Cookie.Expire for expiring the given cookie.
CookieExpireUnlimited indicates that the cookie doesn't expire.
ErrBodyTooLarge is returned if either request or response body exceeds the given limit.
ErrConcurrencyLimit may be returned from ServeConn if the number of concurrenty served connections exceeds Server.Concurrency.
ErrConnectionClosed may be returned from client methods if the server closes connection before returning the first response byte.
ErrDialTimeout is returned when TCP dialing is timed out.
ErrKeepaliveTimeout is returned from ServeConn if the connection lifetime exceeds MaxKeepaliveDuration.
ErrMissingFile may be returned from FormFile when the is no uploaded file associated with the given multipart form key.
ErrNoArgValue is returned when Args value with the given key is missing.
ErrNoFreeConns is returned when no free connections available to the given host.
ErrNoMultipartForm means that the request's Content-Type isn't 'multipart/form-data'.
ErrPerIPConnLimit may be returned from ServeConn if the number of connections per ip exceeds Server.MaxConnsPerIP.
ErrPipelineOverflow may be returned from PipelineClient.Do* if the requests' queue is overflown.
ErrTimeout is returned from timed out calls.

# Structs

Args represents query arguments.
Client implements http client.
Cookie represents HTTP response cookie.
ErrSmallBuffer is returned when the provided buffer size is too small for reading request and/or response headers.
FS represents settings for request handler serving static files from the local filesystem.
HostClient balances http requests among hosts listed in Addr.
LBClient balances requests among available LBClient.Clients.
PipelineClient pipelines requests over a limited set of concurrent connections to the given Addr.
Request represents HTTP request.
RequestCtx contains incoming request and manages outgoing response.
RequestHeader represents HTTP request header.
Response represents HTTP response.
ResponseHeader represents HTTP response header.
Server implements HTTP server.
URI represents URI :) .

# Interfaces

BalancingClient is the interface for clients, which may be passed to LBClient.Clients.
Logger is used for logging formatted messages.

# Type aliases

ByteBuffer provides byte buffer, which can be used with fasthttp API in order to minimize memory allocations.
DialFunc must establish connection to addr.
HijackHandler must process the hijacked connection c.
PathRewriteFunc must return new request path based on arbitrary ctx info such as ctx.Path().
RequestHandler must process incoming requests.
StreamWriter must write data to w.