aboutsummaryrefslogtreecommitdiff
path: root/fs.go
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2018-10-01 14:15:29 +0800
committerGravatar Erik Dubbelboer <erik@dubbelboer.com> 2018-10-01 14:15:29 +0800
commitd4f0cf56d8a7bb271fbd8634d78645bd3c24c9b7 (patch)
tree2bf17d8d3ff14938e770f57d2b95dc19407fca7c /fs.go
parentAdd tcp keepalive (diff)
downloadfasthttp-d4f0cf56d8a7bb271fbd8634d78645bd3c24c9b7.tar.gz
fasthttp-d4f0cf56d8a7bb271fbd8634d78645bd3c24c9b7.tar.bz2
fasthttp-d4f0cf56d8a7bb271fbd8634d78645bd3c24c9b7.zip
Remove fasthttp.ByteBuffer
As advertised in https://github.com/valyala/fasthttp/commit/b5f96d4b4120bb1e09c23ac32baf21a14da4a71d
Diffstat (limited to 'fs.go')
-rw-r--r--fs.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs.go b/fs.go
index f0ea066..7a73a79 100644
--- a/fs.go
+++ b/fs.go
@@ -17,6 +17,7 @@ import (
"time"
"github.com/klauspost/compress/gzip"
+ "github.com/valyala/bytebufferpool"
)
// ServeFileBytesUncompressed returns HTTP response containing file contents
@@ -139,12 +140,12 @@ func NewVHostPathRewriter(slashesCount int) PathRewriteFunc {
if len(host) == 0 {
host = strInvalidHost
}
- b := AcquireByteBuffer()
+ b := bytebufferpool.Get()
b.B = append(b.B, '/')
b.B = append(b.B, host...)
b.B = append(b.B, path...)
ctx.URI().SetPathBytes(b.B)
- ReleaseByteBuffer(b)
+ bytebufferpool.Put(b)
return ctx.Path()
}
@@ -915,7 +916,7 @@ var (
)
func (h *fsHandler) createDirIndex(base *URI, dirPath string, mustCompress bool) (*fsFile, error) {
- w := &ByteBuffer{}
+ w := &bytebufferpool.ByteBuffer{}
basePathEscaped := html.EscapeString(string(base.Path()))
fmt.Fprintf(w, "<html><head><title>%s</title><style>.dir { font-weight: bold }</style></head><body>", basePathEscaped)
@@ -975,7 +976,7 @@ func (h *fsHandler) createDirIndex(base *URI, dirPath string, mustCompress bool)
fmt.Fprintf(w, "</ul></body></html>")
if mustCompress {
- var zbuf ByteBuffer
+ var zbuf bytebufferpool.ByteBuffer
zbuf.B = AppendGzipBytesLevel(zbuf.B, w.B, CompressDefaultCompression)
w = &zbuf
}