go - HTTP/2 请求,但不支持推送

标签 go http2

我开始尝试使用 go http/2 push,这些示例对我不起作用。 请求在 http/2 中(我可以在 firefox 中看到“版本:HTTP/2.0”,并且我有一个扩展来判断服务器是否使用 http/2)。 然而,类似的东西:

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    if pusher, ok := w.(http.Pusher); ok {
        // Push is supported.
        if err := pusher.Push("/app.js", nil); err != nil {
            log.Printf("Failed to push: %v", err)
        }
    } else {
      fmt.Println("Push not supported")
    }
    // ...
})

始终显示“不支持推送”。 有任何调试提示吗?

谢谢

最佳答案

没关系,我找到了,因为我用的是 negroni:https://github.com/urfave/negroni/issues/173

关于go - HTTP/2 请求,但不支持推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44339285/

相关文章:

json - Golang 将 JSON 数组解析成数据结构

function - 如何将 time.Duration 类型传递给 go 函数?

Golang TCP 服务器 : how to write HTTP2 data

http - 在服务到服务通信方面,http2 是否比 http1.1 有性能优势?

swift - 无法使用有界流对执行流式请求

django - HTTP2与Gunicorn

go - 为什么我会收到 Go error "panic: strconv: illegal AppendInt/FormatInt base"

go - 仅使用stdlib在Golang中进行路由

go - 无法安装包

internet-explorer - 如何在 Windows 10 Server 技术预览版中启用 http2