<p>Hi,</p>
<p>i'm currently trying to gzip my handlers, but i'm always getting a " copied 70063 bytes from body stream instead of 126072 bytes " error.</p>
<pre><code>h := router.Handler
h = fasthttp.CompressHandler(h)
log.Fatal(fasthttp.ListenAndServe(":8080", h))
</code></pre>
<p>Any suggestion on how to correctly gzip the responses? Afaik static files served via ServeFiles are already compressed.</p>
<p>Regards</p>
<hr/>**评论:**<br/><br/>dinkumator: <pre><p>Sounds like you might be writing out headers before applying the compression. Hard to know anything without more of your code though.</p></pre>metamatic: <pre><blockquote>
<p>Afaik static files served via ServeFiles are already compressed.</p>
</blockquote>
<p>They're not, or at least not last time I checked, but <a href="https://github.com/lpar/gzipped" rel="nofollow">I wrote something to do that</a>.</p></pre>FPSports: <pre><p><a href="https://godoc.org/github.com/valyala/fasthttp#ServeFile" rel="nofollow">https://godoc.org/github.com/valyala/fasthttp#ServeFile</a></p></pre>metamatic: <pre><p>Oh, I see, that's a feature of fasthttp I wasn't aware of.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传