Fasthttp + fasthttprouter: gzip?

polaris · · 2136 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi,</p> <p>i&#39;m currently trying to gzip my handlers, but i&#39;m always getting a &#34; copied 70063 bytes from body stream instead of 126072 bytes &#34; error.</p> <pre><code>h := router.Handler h = fasthttp.CompressHandler(h) log.Fatal(fasthttp.ListenAndServe(&#34;:8080&#34;, 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&#39;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&#39;s a feature of fasthttp I wasn&#39;t aware of.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

2136 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传