vendor: update github.com/VictoriaMetrics/fasthttp from v1.1.0 to v1.2.0

The v1.2.0 adds HostClient.DoCtx() function, which is needed by https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3747
for implementing fast canceling of pending requests to scrape targets on config update
This commit is contained in:
Aliaksandr Valialkin 2023-02-21 17:48:46 -08:00
parent f04ec714c2
commit ffebc20f6d
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
16 changed files with 232 additions and 186 deletions

2
go.mod
View file

@ -10,7 +10,7 @@ require (
// Do not use the original github.com/valyala/fasthttp because of issues // Do not use the original github.com/valyala/fasthttp because of issues
// like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b // like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b
github.com/VictoriaMetrics/fasthttp v1.1.0 github.com/VictoriaMetrics/fasthttp v1.2.0
github.com/VictoriaMetrics/metrics v1.23.1 github.com/VictoriaMetrics/metrics v1.23.1
github.com/VictoriaMetrics/metricsql v0.56.1 github.com/VictoriaMetrics/metricsql v0.56.1
github.com/aws/aws-sdk-go-v2 v1.17.4 github.com/aws/aws-sdk-go-v2 v1.17.4

4
go.sum
View file

@ -64,8 +64,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY= github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
github.com/VictoriaMetrics/fastcache v1.12.0 h1:vnVi/y9yKDcD9akmc4NqAoqgQhJrOwUF+j9LTgn4QDE= github.com/VictoriaMetrics/fastcache v1.12.0 h1:vnVi/y9yKDcD9akmc4NqAoqgQhJrOwUF+j9LTgn4QDE=
github.com/VictoriaMetrics/fastcache v1.12.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8= github.com/VictoriaMetrics/fastcache v1.12.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8=
github.com/VictoriaMetrics/fasthttp v1.1.0 h1:3crd4YWHsMwu60GUXRH6OstowiFvqrwS4a/ueoLdLL0= github.com/VictoriaMetrics/fasthttp v1.2.0 h1:nd9Wng4DlNtaI27WlYh5mGXCJOmee/2c2blTJwfyU9I=
github.com/VictoriaMetrics/fasthttp v1.1.0/go.mod h1:/7DMcogqd+aaD3G3Hg5kFgoFwlR2uydjiWvoLp5ZTqQ= github.com/VictoriaMetrics/fasthttp v1.2.0/go.mod h1:zv5YSmasAoSyv8sBVexfArzFDIGGTN4TfCKAtAw7IfE=
github.com/VictoriaMetrics/metrics v1.18.1/go.mod h1:ArjwVz7WpgpegX/JpB0zpNF2h2232kErkEnzH1sxMmA= github.com/VictoriaMetrics/metrics v1.18.1/go.mod h1:ArjwVz7WpgpegX/JpB0zpNF2h2232kErkEnzH1sxMmA=
github.com/VictoriaMetrics/metrics v1.23.1 h1:/j8DzeJBxSpL2qSIdqnRFLvQQhbJyJbbEi22yMm7oL0= github.com/VictoriaMetrics/metrics v1.23.1 h1:/j8DzeJBxSpL2qSIdqnRFLvQQhbJyJbbEi22yMm7oL0=
github.com/VictoriaMetrics/metrics v1.23.1/go.mod h1:rAr/llLpEnAdTehiNlUxKgnjcOuROSzpw0GvjpEbvFc= github.com/VictoriaMetrics/metrics v1.23.1/go.mod h1:rAr/llLpEnAdTehiNlUxKgnjcOuROSzpw0GvjpEbvFc=

View file

@ -1,3 +1,4 @@
//go:build !amd64 && !arm64 && !ppc64
// +build !amd64,!arm64,!ppc64 // +build !amd64,!arm64,!ppc64
package fasthttp package fasthttp

View file

@ -1,3 +1,4 @@
//go:build amd64 || arm64 || ppc64
// +build amd64 arm64 ppc64 // +build amd64 arm64 ppc64
package fasthttp package fasthttp

View file

@ -3,6 +3,7 @@ package fasthttp
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"context"
"crypto/tls" "crypto/tls"
"errors" "errors"
"fmt" "fmt"
@ -872,17 +873,40 @@ func (c *HostClient) DoDeadline(req *Request, resp *Response, deadline time.Time
return clientDoDeadline(req, resp, deadline, c) return clientDoDeadline(req, resp, deadline, c)
} }
// DoCtx performs the given request and waits for response until
// the given context is cancelled or deadline is reached.
//
// Request must contain at least non-zero RequestURI with full url (including
// scheme and host) or non-zero Host header + RequestURI.
//
// The function doesn't follow redirects. Use Get* for following redirects.
//
// Response is ignored if resp is nil.
//
// ErrTimeout is returned if the response wasn't returned until
// the deadline provided by the given context.
//
// ErrNoFreeConns is returned if all HostClient.MaxConns connections
// to the host are busy.
//
// It is recommended obtaining req and resp via AcquireRequest
// and AcquireResponse in performance-critical code.
func (c *HostClient) DoCtx(ctx context.Context, req *Request, resp *Response) error {
return clientDoCtx(ctx, req, resp, c)
}
func clientDoTimeout(req *Request, resp *Response, timeout time.Duration, c clientDoer) error { func clientDoTimeout(req *Request, resp *Response, timeout time.Duration, c clientDoer) error {
deadline := time.Now().Add(timeout) deadline := time.Now().Add(timeout)
return clientDoDeadline(req, resp, deadline, c) return clientDoDeadline(req, resp, deadline, c)
} }
func clientDoDeadline(req *Request, resp *Response, deadline time.Time, c clientDoer) error { func clientDoDeadline(req *Request, resp *Response, deadline time.Time, c clientDoer) error {
timeout := -time.Since(deadline) ctx, cancel := context.WithDeadline(context.Background(), deadline)
if timeout <= 0 { defer cancel()
return ErrTimeout return clientDoCtx(ctx, req, resp, c)
} }
func clientDoCtx(ctx context.Context, req *Request, resp *Response, c clientDoer) error {
var ch chan error var ch chan error
chv := errorChPool.Get() chv := errorChPool.Get()
if chv == nil { if chv == nil {
@ -910,7 +934,6 @@ func clientDoDeadline(req *Request, resp *Response, deadline time.Time, c client
ch <- c.Do(reqCopy, respCopy) ch <- c.Do(reqCopy, respCopy)
}() }()
tc := acquireTimer(timeout)
var err error var err error
select { select {
case err = <-ch: case err = <-ch:
@ -921,10 +944,12 @@ func clientDoDeadline(req *Request, resp *Response, deadline time.Time, c client
ReleaseResponse(respCopy) ReleaseResponse(respCopy)
ReleaseRequest(reqCopy) ReleaseRequest(reqCopy)
errorChPool.Put(chv) errorChPool.Put(chv)
case <-tc.C: case <-ctx.Done():
err = ErrTimeout err = ctx.Err()
if errors.Is(err, context.DeadlineExceeded) {
err = ErrTimeout
}
} }
releaseTimer(tc)
return err return err
} }

View file

@ -127,11 +127,11 @@ var (
// //
// Supported compression levels are: // Supported compression levels are:
// //
// * CompressNoCompression // - CompressNoCompression
// * CompressBestSpeed // - CompressBestSpeed
// * CompressBestCompression // - CompressBestCompression
// * CompressDefaultCompression // - CompressDefaultCompression
// * CompressHuffmanOnly // - CompressHuffmanOnly
func AppendGzipBytesLevel(dst, src []byte, level int) []byte { func AppendGzipBytesLevel(dst, src []byte, level int) []byte {
w := &byteSliceWriter{dst} w := &byteSliceWriter{dst}
WriteGzipLevel(w, src, level) WriteGzipLevel(w, src, level)
@ -143,11 +143,11 @@ func AppendGzipBytesLevel(dst, src []byte, level int) []byte {
// //
// Supported compression levels are: // Supported compression levels are:
// //
// * CompressNoCompression // - CompressNoCompression
// * CompressBestSpeed // - CompressBestSpeed
// * CompressBestCompression // - CompressBestCompression
// * CompressDefaultCompression // - CompressDefaultCompression
// * CompressHuffmanOnly // - CompressHuffmanOnly
func WriteGzipLevel(w io.Writer, p []byte, level int) (int, error) { func WriteGzipLevel(w io.Writer, p []byte, level int) (int, error) {
switch w.(type) { switch w.(type) {
case *byteSliceWriter, case *byteSliceWriter,
@ -224,11 +224,11 @@ func AppendGunzipBytes(dst, src []byte) ([]byte, error) {
// //
// Supported compression levels are: // Supported compression levels are:
// //
// * CompressNoCompression // - CompressNoCompression
// * CompressBestSpeed // - CompressBestSpeed
// * CompressBestCompression // - CompressBestCompression
// * CompressDefaultCompression // - CompressDefaultCompression
// * CompressHuffmanOnly // - CompressHuffmanOnly
func AppendDeflateBytesLevel(dst, src []byte, level int) []byte { func AppendDeflateBytesLevel(dst, src []byte, level int) []byte {
w := &byteSliceWriter{dst} w := &byteSliceWriter{dst}
WriteDeflateLevel(w, src, level) WriteDeflateLevel(w, src, level)
@ -240,11 +240,11 @@ func AppendDeflateBytesLevel(dst, src []byte, level int) []byte {
// //
// Supported compression levels are: // Supported compression levels are:
// //
// * CompressNoCompression // - CompressNoCompression
// * CompressBestSpeed // - CompressBestSpeed
// * CompressBestCompression // - CompressBestCompression
// * CompressDefaultCompression // - CompressDefaultCompression
// * CompressHuffmanOnly // - CompressHuffmanOnly
func WriteDeflateLevel(w io.Writer, p []byte, level int) (int, error) { func WriteDeflateLevel(w io.Writer, p []byte, level int) (int, error) {
switch w.(type) { switch w.(type) {
case *byteSliceWriter, case *byteSliceWriter,

View file

@ -3,38 +3,57 @@ Package fasthttp provides fast HTTP server and client API.
Fasthttp provides the following features: Fasthttp provides the following features:
* Optimized for speed. Easily handles more than 100K qps and more than 1M - Optimized for speed. Easily handles more than 100K qps and more than 1M
concurrent keep-alive connections on modern hardware. concurrent keep-alive connections on modern hardware.
* Optimized for low memory usage.
* Easy 'Connection: Upgrade' support via RequestCtx.Hijack.
* Server supports requests' pipelining. Multiple requests may be read from
a single network packet and multiple responses may be sent in a single
network packet. This may be useful for highly loaded REST services.
* Server provides the following anti-DoS limits:
* The number of concurrent connections. - Optimized for low memory usage.
* The number of concurrent connections per client IP.
* The number of requests per connection.
* Request read timeout.
* Response write timeout.
* Maximum request header size.
* Maximum request body size.
* Maximum request execution time.
* Maximum keep-alive connection lifetime.
* Early filtering out non-GET requests.
* A lot of additional useful info is exposed to request handler: - Easy 'Connection: Upgrade' support via RequestCtx.Hijack.
* Server and client address. - Server supports requests' pipelining. Multiple requests may be read from
* Per-request logger. a single network packet and multiple responses may be sent in a single
* Unique request id. network packet. This may be useful for highly loaded REST services.
* Request start time.
* Connection start time.
* Request sequence number for the current connection.
* Client supports automatic retry on idempotent requests' failure. - Server provides the following anti-DoS limits:
* Fasthttp API is designed with the ability to extend existing client
and server implementations or to write custom client and server - The number of concurrent connections.
implementations from scratch.
- The number of concurrent connections per client IP.
- The number of requests per connection.
- Request read timeout.
- Response write timeout.
- Maximum request header size.
- Maximum request body size.
- Maximum request execution time.
- Maximum keep-alive connection lifetime.
- Early filtering out non-GET requests.
- A lot of additional useful info is exposed to request handler:
- Server and client address.
- Per-request logger.
- Unique request id.
- Request start time.
- Connection start time.
- Request sequence number for the current connection.
- Client supports automatic retry on idempotent requests' failure.
- Fasthttp API is designed with the ability to extend existing client
and server implementations or to write custom client and server
implementations from scratch.
*/ */
package fasthttp package fasthttp

View file

@ -51,8 +51,8 @@ func ServeFileUncompressed(ctx *RequestCtx, path string) {
// //
// HTTP response may contain uncompressed file contents in the following cases: // HTTP response may contain uncompressed file contents in the following cases:
// //
// * Missing 'Accept-Encoding: gzip' request header. // - Missing 'Accept-Encoding: gzip' request header.
// * No write access to directory containing the file. // - No write access to directory containing the file.
// //
// Directory contents is returned if path points to directory. // Directory contents is returned if path points to directory.
// //
@ -69,8 +69,8 @@ func ServeFileBytes(ctx *RequestCtx, path []byte) {
// //
// HTTP response may contain uncompressed file contents in the following cases: // HTTP response may contain uncompressed file contents in the following cases:
// //
// * Missing 'Accept-Encoding: gzip' request header. // - Missing 'Accept-Encoding: gzip' request header.
// * No write access to directory containing the file. // - No write access to directory containing the file.
// //
// Directory contents is returned if path points to directory. // Directory contents is returned if path points to directory.
// //
@ -123,12 +123,11 @@ type PathRewriteFunc func(ctx *RequestCtx) []byte
// //
// Examples: // Examples:
// //
// * host=foobar.com, slashesCount=0, original path="/foo/bar". // - host=foobar.com, slashesCount=0, original path="/foo/bar".
// Resulting path: "/foobar.com/foo/bar" // Resulting path: "/foobar.com/foo/bar"
// //
// * host=img.aaa.com, slashesCount=1, original path="/images/123/456.jpg" // - host=img.aaa.com, slashesCount=1, original path="/images/123/456.jpg"
// Resulting path: "/img.aaa.com/123/456.jpg" // Resulting path: "/img.aaa.com/123/456.jpg"
//
func NewVHostPathRewriter(slashesCount int) PathRewriteFunc { func NewVHostPathRewriter(slashesCount int) PathRewriteFunc {
return func(ctx *RequestCtx) []byte { return func(ctx *RequestCtx) []byte {
path := stripLeadingSlashes(ctx.Path(), slashesCount) path := stripLeadingSlashes(ctx.Path(), slashesCount)
@ -157,9 +156,9 @@ var strInvalidHost = []byte("invalid-host")
// //
// Examples: // Examples:
// //
// * slashesCount = 0, original path: "/foo/bar", result: "/foo/bar" // - slashesCount = 0, original path: "/foo/bar", result: "/foo/bar"
// * slashesCount = 1, original path: "/foo/bar", result: "/bar" // - slashesCount = 1, original path: "/foo/bar", result: "/bar"
// * slashesCount = 2, original path: "/foo/bar", result: "" // - slashesCount = 2, original path: "/foo/bar", result: ""
// //
// The returned path rewriter may be used as FS.PathRewrite . // The returned path rewriter may be used as FS.PathRewrite .
func NewPathSlashesStripper(slashesCount int) PathRewriteFunc { func NewPathSlashesStripper(slashesCount int) PathRewriteFunc {
@ -173,9 +172,9 @@ func NewPathSlashesStripper(slashesCount int) PathRewriteFunc {
// //
// Examples: // Examples:
// //
// * prefixSize = 0, original path: "/foo/bar", result: "/foo/bar" // - prefixSize = 0, original path: "/foo/bar", result: "/foo/bar"
// * prefixSize = 3, original path: "/foo/bar", result: "o/bar" // - prefixSize = 3, original path: "/foo/bar", result: "o/bar"
// * prefixSize = 7, original path: "/foo/bar", result: "r" // - prefixSize = 7, original path: "/foo/bar", result: "r"
// //
// The returned path rewriter may be used as FS.PathRewrite . // The returned path rewriter may be used as FS.PathRewrite .
func NewPathPrefixStripper(prefixSize int) PathRewriteFunc { func NewPathPrefixStripper(prefixSize int) PathRewriteFunc {
@ -273,9 +272,9 @@ const FSHandlerCacheDuration = 10 * time.Second
// from requested path before searching requested file in the root folder. // from requested path before searching requested file in the root folder.
// Examples: // Examples:
// //
// * stripSlashes = 0, original path: "/foo/bar", result: "/foo/bar" // - stripSlashes = 0, original path: "/foo/bar", result: "/foo/bar"
// * stripSlashes = 1, original path: "/foo/bar", result: "/bar" // - stripSlashes = 1, original path: "/foo/bar", result: "/bar"
// * stripSlashes = 2, original path: "/foo/bar", result: "" // - stripSlashes = 2, original path: "/foo/bar", result: ""
// //
// The returned request handler automatically generates index pages // The returned request handler automatically generates index pages
// for directories without index.html. // for directories without index.html.

View file

@ -90,8 +90,8 @@ func (h *ResponseHeader) SetContentRange(startPos, endPos, contentLength int) {
// SetByteRange sets 'Range: bytes=startPos-endPos' header. // SetByteRange sets 'Range: bytes=startPos-endPos' header.
// //
// * If startPos is negative, then 'bytes=-startPos' value is set. // - If startPos is negative, then 'bytes=-startPos' value is set.
// * If endPos is negative, then 'bytes=startPos-' value is set. // - If endPos is negative, then 'bytes=startPos-' value is set.
func (h *RequestHeader) SetByteRange(startPos, endPos int) { func (h *RequestHeader) SetByteRange(startPos, endPos int) {
h.parseRawHeaders() h.parseRawHeaders()
@ -1985,9 +1985,9 @@ func normalizeHeaderKey(b []byte) {
// after dashes are also uppercased. All the other letters are lowercased. // after dashes are also uppercased. All the other letters are lowercased.
// Examples: // Examples:
// //
// * coNTENT-TYPe -> Content-Type // - coNTENT-TYPe -> Content-Type
// * HOST -> Host // - HOST -> Host
// * foo-bar-baz -> Foo-Bar-Baz // - foo-bar-baz -> Foo-Bar-Baz
func AppendNormalizedHeaderKey(dst []byte, key string) []byte { func AppendNormalizedHeaderKey(dst []byte, key string) []byte {
dst = append(dst, key...) dst = append(dst, key...)
normalizeHeaderKey(dst[len(dst)-len(key):]) normalizeHeaderKey(dst[len(dst)-len(key):])
@ -2001,9 +2001,9 @@ func AppendNormalizedHeaderKey(dst []byte, key string) []byte {
// after dashes are also uppercased. All the other letters are lowercased. // after dashes are also uppercased. All the other letters are lowercased.
// Examples: // Examples:
// //
// * coNTENT-TYPe -> Content-Type // - coNTENT-TYPe -> Content-Type
// * HOST -> Host // - HOST -> Host
// * foo-bar-baz -> Foo-Bar-Baz // - foo-bar-baz -> Foo-Bar-Baz
func AppendNormalizedHeaderKeyBytes(dst, key []byte) []byte { func AppendNormalizedHeaderKeyBytes(dst, key []byte) []byte {
return AppendNormalizedHeaderKey(dst, b2s(key)) return AppendNormalizedHeaderKey(dst, b2s(key))
} }

View file

@ -216,14 +216,14 @@ func (resp *Response) IsBodyStream() bool {
// //
// This function may be used in the following cases: // This function may be used in the following cases:
// //
// * if request body is too big (more than 10MB). // - if request body is too big (more than 10MB).
// * if request body is streamed from slow external sources. // - if request body is streamed from slow external sources.
// * if request body must be streamed to the server in chunks // - if request body must be streamed to the server in chunks
// (aka `http client push` or `chunked transfer-encoding`). // (aka `http client push` or `chunked transfer-encoding`).
// //
// Note that GET and HEAD requests cannot have body. // Note that GET and HEAD requests cannot have body.
// //
/// See also SetBodyStream. // / See also SetBodyStream.
func (req *Request) SetBodyStreamWriter(sw StreamWriter) { func (req *Request) SetBodyStreamWriter(sw StreamWriter) {
sr := NewStreamReader(sw) sr := NewStreamReader(sw)
req.SetBodyStream(sr, -1) req.SetBodyStream(sr, -1)
@ -233,9 +233,9 @@ func (req *Request) SetBodyStreamWriter(sw StreamWriter) {
// //
// This function may be used in the following cases: // This function may be used in the following cases:
// //
// * if response body is too big (more than 10MB). // - if response body is too big (more than 10MB).
// * if response body is streamed from slow external sources. // - if response body is streamed from slow external sources.
// * if response body must be streamed to the client in chunks // - if response body must be streamed to the client in chunks
// (aka `http server push` or `chunked transfer-encoding`). // (aka `http server push` or `chunked transfer-encoding`).
// //
// See also SetBodyStream. // See also SetBodyStream.
@ -831,11 +831,11 @@ func (resp *Response) resetSkipHeader() {
// //
// If MayContinue returns true, the caller must: // If MayContinue returns true, the caller must:
// //
// - Either send StatusExpectationFailed response if request headers don't // - Either send StatusExpectationFailed response if request headers don't
// satisfy the caller. // satisfy the caller.
// - Or send StatusContinue response before reading request body // - Or send StatusContinue response before reading request body
// with ContinueReadBody. // with ContinueReadBody.
// - Or close the connection. // - Or close the connection.
// //
// io.EOF is returned if r is closed before reading the first header byte. // io.EOF is returned if r is closed before reading the first header byte.
func (req *Request) Read(r *bufio.Reader) error { func (req *Request) Read(r *bufio.Reader) error {
@ -857,11 +857,11 @@ var errGetOnly = errors.New("non-GET request received")
// //
// If MayContinue returns true, the caller must: // If MayContinue returns true, the caller must:
// //
// - Either send StatusExpectationFailed response if request headers don't // - Either send StatusExpectationFailed response if request headers don't
// satisfy the caller. // satisfy the caller.
// - Or send StatusContinue response before reading request body // - Or send StatusContinue response before reading request body
// with ContinueReadBody. // with ContinueReadBody.
// - Or close the connection. // - Or close the connection.
// //
// io.EOF is returned if r is closed before reading the first header byte. // io.EOF is returned if r is closed before reading the first header byte.
func (req *Request) ReadLimitBody(r *bufio.Reader, maxBodySize int) error { func (req *Request) ReadLimitBody(r *bufio.Reader, maxBodySize int) error {
@ -900,11 +900,11 @@ func (req *Request) readLimitBody(r *bufio.Reader, maxBodySize int, getOnly bool
// //
// The caller must do one of the following actions if MayContinue returns true: // The caller must do one of the following actions if MayContinue returns true:
// //
// - Either send StatusExpectationFailed response if request headers don't // - Either send StatusExpectationFailed response if request headers don't
// satisfy the caller. // satisfy the caller.
// - Or send StatusContinue response before reading request body // - Or send StatusContinue response before reading request body
// with ContinueReadBody. // with ContinueReadBody.
// - Or close the connection. // - Or close the connection.
func (req *Request) MayContinue() bool { func (req *Request) MayContinue() bool {
return bytes.Equal(req.Header.peek(strExpect), str100Continue) return bytes.Equal(req.Header.peek(strExpect), str100Continue)
} }
@ -1138,11 +1138,11 @@ func (resp *Response) WriteGzip(w *bufio.Writer) error {
// //
// Level is the desired compression level: // Level is the desired compression level:
// //
// * CompressNoCompression // - CompressNoCompression
// * CompressBestSpeed // - CompressBestSpeed
// * CompressBestCompression // - CompressBestCompression
// * CompressDefaultCompression // - CompressDefaultCompression
// * CompressHuffmanOnly // - CompressHuffmanOnly
// //
// The method gzips response body and sets 'Content-Encoding: gzip' // The method gzips response body and sets 'Content-Encoding: gzip'
// header before writing response to w. // header before writing response to w.
@ -1169,11 +1169,11 @@ func (resp *Response) WriteDeflate(w *bufio.Writer) error {
// //
// Level is the desired compression level: // Level is the desired compression level:
// //
// * CompressNoCompression // - CompressNoCompression
// * CompressBestSpeed // - CompressBestSpeed
// * CompressBestCompression // - CompressBestCompression
// * CompressDefaultCompression // - CompressDefaultCompression
// * CompressHuffmanOnly // - CompressHuffmanOnly
// //
// The method deflates response body and sets 'Content-Encoding: deflate' // The method deflates response body and sets 'Content-Encoding: deflate'
// header before writing response to w. // header before writing response to w.

View file

@ -318,11 +318,11 @@ func CompressHandler(h RequestHandler) RequestHandler {
// //
// Level is the desired compression level: // Level is the desired compression level:
// //
// * CompressNoCompression // - CompressNoCompression
// * CompressBestSpeed // - CompressBestSpeed
// * CompressBestCompression // - CompressBestCompression
// * CompressDefaultCompression // - CompressDefaultCompression
// * CompressHuffmanOnly // - CompressHuffmanOnly
func CompressHandlerLevel(h RequestHandler, level int) RequestHandler { func CompressHandlerLevel(h RequestHandler, level int) RequestHandler {
return func(ctx *RequestCtx) { return func(ctx *RequestCtx) {
h(ctx) h(ctx)
@ -405,8 +405,8 @@ type HijackHandler func(c net.Conn)
// //
// The server skips calling the handler in the following cases: // The server skips calling the handler in the following cases:
// //
// * 'Connection: close' header exists in either request or response. // - 'Connection: close' header exists in either request or response.
// * Unexpected error during response writing to the connection. // - Unexpected error during response writing to the connection.
// //
// The server stops processing requests from hijacked connections. // The server stops processing requests from hijacked connections.
// Server limits such as Concurrency, ReadTimeout, WriteTimeout, etc. // Server limits such as Concurrency, ReadTimeout, WriteTimeout, etc.
@ -417,9 +417,8 @@ type HijackHandler func(c net.Conn)
// Arbitrary 'Connection: Upgrade' protocols may be implemented // Arbitrary 'Connection: Upgrade' protocols may be implemented
// with HijackHandler. For instance, // with HijackHandler. For instance,
// //
// * WebSocket ( https://en.wikipedia.org/wiki/WebSocket ) // - WebSocket ( https://en.wikipedia.org/wiki/WebSocket )
// * HTTP/2.0 ( https://en.wikipedia.org/wiki/HTTP/2 ) // - HTTP/2.0 ( https://en.wikipedia.org/wiki/HTTP/2 )
//
func (ctx *RequestCtx) Hijack(handler HijackHandler) { func (ctx *RequestCtx) Hijack(handler HijackHandler) {
ctx.hijackHandler = handler ctx.hijackHandler = handler
} }
@ -759,15 +758,15 @@ func SaveMultipartFile(fh *multipart.FileHeader, path string) error {
// //
// The value is searched in the following places: // The value is searched in the following places:
// //
// * Query string. // - Query string.
// * POST or PUT body. // - POST or PUT body.
// //
// There are more fine-grained methods for obtaining form values: // There are more fine-grained methods for obtaining form values:
// //
// * QueryArgs for obtaining values from query string. // - QueryArgs for obtaining values from query string.
// * PostArgs for obtaining values from POST or PUT body. // - PostArgs for obtaining values from POST or PUT body.
// * MultipartForm for obtaining values from multipart form. // - MultipartForm for obtaining values from multipart form.
// * FormFile for obtaining uploaded files. // - FormFile for obtaining uploaded files.
// //
// The returned value is valid until returning from RequestHandler. // The returned value is valid until returning from RequestHandler.
func (ctx *RequestCtx) FormValue(key string) []byte { func (ctx *RequestCtx) FormValue(key string) []byte {
@ -896,10 +895,10 @@ func (ctx *RequestCtx) SuccessString(contentType, body string) {
// //
// statusCode must have one of the following values: // statusCode must have one of the following values:
// //
// * StatusMovedPermanently (301) // - StatusMovedPermanently (301)
// * StatusFound (302) // - StatusFound (302)
// * StatusSeeOther (303) // - StatusSeeOther (303)
// * StatusTemporaryRedirect (307) // - StatusTemporaryRedirect (307)
// //
// All other statusCode values are replaced by StatusFound (302). // All other statusCode values are replaced by StatusFound (302).
// //
@ -918,10 +917,10 @@ func (ctx *RequestCtx) Redirect(uri string, statusCode int) {
// //
// statusCode must have one of the following values: // statusCode must have one of the following values:
// //
// * StatusMovedPermanently (301) // - StatusMovedPermanently (301)
// * StatusFound (302) // - StatusFound (302)
// * StatusSeeOther (303) // - StatusSeeOther (303)
// * StatusTemporaryRedirect (307) // - StatusTemporaryRedirect (307)
// //
// All other statusCode values are replaced by StatusFound (302). // All other statusCode values are replaced by StatusFound (302).
// //
@ -1056,9 +1055,9 @@ func (ctx *RequestCtx) SetBodyStream(bodyStream io.Reader, bodySize int) {
// //
// This function may be used in the following cases: // This function may be used in the following cases:
// //
// * if response body is too big (more than 10MB). // - if response body is too big (more than 10MB).
// * if response body is streamed from slow external sources. // - if response body is streamed from slow external sources.
// * if response body must be streamed to the client in chunks. // - if response body must be streamed to the client in chunks.
// (aka `http server push`). // (aka `http server push`).
func (ctx *RequestCtx) SetBodyStreamWriter(sw StreamWriter) { func (ctx *RequestCtx) SetBodyStreamWriter(sw StreamWriter) {
ctx.Response.SetBodyStreamWriter(sw) ctx.Response.SetBodyStreamWriter(sw)

View file

@ -13,12 +13,12 @@ import (
// //
// This function has the following additional features comparing to net.Dial: // This function has the following additional features comparing to net.Dial:
// //
// * It reduces load on DNS resolver by caching resolved TCP addressed // - It reduces load on DNS resolver by caching resolved TCP addressed
// for DefaultDNSCacheDuration. // for DefaultDNSCacheDuration.
// * It dials all the resolved TCP addresses in round-robin manner until // - It dials all the resolved TCP addresses in round-robin manner until
// connection is established. This may be useful if certain addresses // connection is established. This may be useful if certain addresses
// are temporarily unreachable. // are temporarily unreachable.
// * It returns ErrDialTimeout if connection cannot be established during // - It returns ErrDialTimeout if connection cannot be established during
// DefaultDialTimeout seconds. Use DialTimeout for customizing dial timeout. // DefaultDialTimeout seconds. Use DialTimeout for customizing dial timeout.
// //
// This dialer is intended for custom code wrapping before passing // This dialer is intended for custom code wrapping before passing
@ -29,9 +29,9 @@ import (
// //
// The addr passed to the function must contain port. Example addr values: // The addr passed to the function must contain port. Example addr values:
// //
// * foobar.baz:443 // - foobar.baz:443
// * foo.bar:80 // - foo.bar:80
// * aaa.com:8080 // - aaa.com:8080
func Dial(addr string) (net.Conn, error) { func Dial(addr string) (net.Conn, error) {
return getDialer(DefaultDialTimeout, false)(addr) return getDialer(DefaultDialTimeout, false)(addr)
} }
@ -40,9 +40,9 @@ func Dial(addr string) (net.Conn, error) {
// //
// This function has the following additional features comparing to net.Dial: // This function has the following additional features comparing to net.Dial:
// //
// * It reduces load on DNS resolver by caching resolved TCP addressed // - It reduces load on DNS resolver by caching resolved TCP addressed
// for DefaultDNSCacheDuration. // for DefaultDNSCacheDuration.
// * It dials all the resolved TCP addresses in round-robin manner until // - It dials all the resolved TCP addresses in round-robin manner until
// connection is established. This may be useful if certain addresses // connection is established. This may be useful if certain addresses
// are temporarily unreachable. // are temporarily unreachable.
// //
@ -54,9 +54,9 @@ func Dial(addr string) (net.Conn, error) {
// //
// The addr passed to the function must contain port. Example addr values: // The addr passed to the function must contain port. Example addr values:
// //
// * foobar.baz:443 // - foobar.baz:443
// * foo.bar:80 // - foo.bar:80
// * aaa.com:8080 // - aaa.com:8080
func DialTimeout(addr string, timeout time.Duration) (net.Conn, error) { func DialTimeout(addr string, timeout time.Duration) (net.Conn, error) {
return getDialer(timeout, false)(addr) return getDialer(timeout, false)(addr)
} }
@ -65,12 +65,12 @@ func DialTimeout(addr string, timeout time.Duration) (net.Conn, error) {
// //
// This function has the following additional features comparing to net.Dial: // This function has the following additional features comparing to net.Dial:
// //
// * It reduces load on DNS resolver by caching resolved TCP addressed // - It reduces load on DNS resolver by caching resolved TCP addressed
// for DefaultDNSCacheDuration. // for DefaultDNSCacheDuration.
// * It dials all the resolved TCP addresses in round-robin manner until // - It dials all the resolved TCP addresses in round-robin manner until
// connection is established. This may be useful if certain addresses // connection is established. This may be useful if certain addresses
// are temporarily unreachable. // are temporarily unreachable.
// * It returns ErrDialTimeout if connection cannot be established during // - It returns ErrDialTimeout if connection cannot be established during
// DefaultDialTimeout seconds. Use DialDualStackTimeout for custom dial // DefaultDialTimeout seconds. Use DialDualStackTimeout for custom dial
// timeout. // timeout.
// //
@ -82,9 +82,9 @@ func DialTimeout(addr string, timeout time.Duration) (net.Conn, error) {
// //
// The addr passed to the function must contain port. Example addr values: // The addr passed to the function must contain port. Example addr values:
// //
// * foobar.baz:443 // - foobar.baz:443
// * foo.bar:80 // - foo.bar:80
// * aaa.com:8080 // - aaa.com:8080
func DialDualStack(addr string) (net.Conn, error) { func DialDualStack(addr string) (net.Conn, error) {
return getDialer(DefaultDialTimeout, true)(addr) return getDialer(DefaultDialTimeout, true)(addr)
} }
@ -94,9 +94,9 @@ func DialDualStack(addr string) (net.Conn, error) {
// //
// This function has the following additional features comparing to net.Dial: // This function has the following additional features comparing to net.Dial:
// //
// * It reduces load on DNS resolver by caching resolved TCP addressed // - It reduces load on DNS resolver by caching resolved TCP addressed
// for DefaultDNSCacheDuration. // for DefaultDNSCacheDuration.
// * It dials all the resolved TCP addresses in round-robin manner until // - It dials all the resolved TCP addresses in round-robin manner until
// connection is established. This may be useful if certain addresses // connection is established. This may be useful if certain addresses
// are temporarily unreachable. // are temporarily unreachable.
// //
@ -108,9 +108,9 @@ func DialDualStack(addr string) (net.Conn, error) {
// //
// The addr passed to the function must contain port. Example addr values: // The addr passed to the function must contain port. Example addr values:
// //
// * foobar.baz:443 // - foobar.baz:443
// * foo.bar:80 // - foo.bar:80
// * aaa.com:8080 // - aaa.com:8080
func DialDualStackTimeout(addr string, timeout time.Duration) (net.Conn, error) { func DialDualStackTimeout(addr string, timeout time.Duration) (net.Conn, error) {
return getDialer(timeout, true)(addr) return getDialer(timeout, true)(addr)
} }

View file

@ -356,9 +356,9 @@ func (u *URI) RequestURI() []byte {
// //
// Examples: // Examples:
// //
// * For /foo/bar/baz.html path returns baz.html. // - For /foo/bar/baz.html path returns baz.html.
// * For /foo/bar/ returns empty byte slice. // - For /foo/bar/ returns empty byte slice.
// * For /foobar.js returns foobar.js. // - For /foobar.js returns foobar.js.
func (u *URI) LastPathSegment() []byte { func (u *URI) LastPathSegment() []byte {
path := u.Path() path := u.Path()
n := bytes.LastIndexByte(path, '/') n := bytes.LastIndexByte(path, '/')
@ -372,14 +372,14 @@ func (u *URI) LastPathSegment() []byte {
// //
// The following newURI types are accepted: // The following newURI types are accepted:
// //
// * Absolute, i.e. http://foobar.com/aaa/bb?cc . In this case the original // - Absolute, i.e. http://foobar.com/aaa/bb?cc . In this case the original
// uri is replaced by newURI. // uri is replaced by newURI.
// * Absolute without scheme, i.e. //foobar.com/aaa/bb?cc. In this case // - Absolute without scheme, i.e. //foobar.com/aaa/bb?cc. In this case
// the original scheme is preserved. // the original scheme is preserved.
// * Missing host, i.e. /aaa/bb?cc . In this case only RequestURI part // - Missing host, i.e. /aaa/bb?cc . In this case only RequestURI part
// of the original uri is replaced. // of the original uri is replaced.
// * Relative path, i.e. xx?yy=abc . In this case the original RequestURI // - Relative path, i.e. xx?yy=abc . In this case the original RequestURI
// is updated according to the new relative path. // is updated according to the new relative path.
func (u *URI) Update(newURI string) { func (u *URI) Update(newURI string) {
u.UpdateBytes(s2b(newURI)) u.UpdateBytes(s2b(newURI))
} }
@ -388,14 +388,14 @@ func (u *URI) Update(newURI string) {
// //
// The following newURI types are accepted: // The following newURI types are accepted:
// //
// * Absolute, i.e. http://foobar.com/aaa/bb?cc . In this case the original // - Absolute, i.e. http://foobar.com/aaa/bb?cc . In this case the original
// uri is replaced by newURI. // uri is replaced by newURI.
// * Absolute without scheme, i.e. //foobar.com/aaa/bb?cc. In this case // - Absolute without scheme, i.e. //foobar.com/aaa/bb?cc. In this case
// the original scheme is preserved. // the original scheme is preserved.
// * Missing host, i.e. /aaa/bb?cc . In this case only RequestURI part // - Missing host, i.e. /aaa/bb?cc . In this case only RequestURI part
// of the original uri is replaced. // of the original uri is replaced.
// * Relative path, i.e. xx?yy=abc . In this case the original RequestURI // - Relative path, i.e. xx?yy=abc . In this case the original RequestURI
// is updated according to the new relative path. // is updated according to the new relative path.
func (u *URI) UpdateBytes(newURI []byte) { func (u *URI) UpdateBytes(newURI []byte) {
u.requestURI = u.updateBytes(newURI, u.requestURI) u.requestURI = u.updateBytes(newURI, u.requestURI)
} }

View file

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
package fasthttp package fasthttp

View file

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
package fasthttp package fasthttp

4
vendor/modules.txt vendored
View file

@ -63,8 +63,8 @@ github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service
# github.com/VictoriaMetrics/fastcache v1.12.0 # github.com/VictoriaMetrics/fastcache v1.12.0
## explicit; go 1.13 ## explicit; go 1.13
github.com/VictoriaMetrics/fastcache github.com/VictoriaMetrics/fastcache
# github.com/VictoriaMetrics/fasthttp v1.1.0 # github.com/VictoriaMetrics/fasthttp v1.2.0
## explicit; go 1.13 ## explicit; go 1.19
github.com/VictoriaMetrics/fasthttp github.com/VictoriaMetrics/fasthttp
github.com/VictoriaMetrics/fasthttp/fasthttputil github.com/VictoriaMetrics/fasthttp/fasthttputil
github.com/VictoriaMetrics/fasthttp/stackless github.com/VictoriaMetrics/fasthttp/stackless