Fasthttp + fasthttprouter: gzip?

polaris · 2016-07-22 17:00:11 · 2194 次点击    
这是一个分享于 2016-07-22 17:00:11 的资源,其中的信息可能已经有所发展或是发生改变。

Hi,

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.

h := router.Handler
h = fasthttp.CompressHandler(h)
log.Fatal(fasthttp.ListenAndServe(":8080", h))

Any suggestion on how to correctly gzip the responses? Afaik static files served via ServeFiles are already compressed.

Regards


评论:

dinkumator:

Sounds like you might be writing out headers before applying the compression. Hard to know anything without more of your code though.

metamatic:

Afaik static files served via ServeFiles are already compressed.

They're not, or at least not last time I checked, but I wrote something to do that.

FPSports:

https://godoc.org/github.com/valyala/fasthttp#ServeFile

metamatic:

Oh, I see, that's a feature of fasthttp I wasn't aware of.


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

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