如何在Go中通过http://进行仅限HTTP2的请求?

huangapple go评论70阅读模式
英文:

How do I make a HTTP2-only request over http:// in Go?

问题

我正在使用Go 1.6,并且想要通过http://进行仅限HTTP2的请求。

目前尝试这样做会导致以下错误:

>Head http://localhost:2076/completed/764c1b6bc55548707507a2dd25570483a7216bf4: http2: unsupported scheme

为了强制使用http2,我相信我需要将http.Client.Transport.TLSConfig.NextProtos设置为[]string{"h2"}

还需要什么?

英文:

I'm using Go 1.6 and want to make a HTTP2-only request over http://.

Attempting to do this currently results in:

>Head http://localhost:2076/completed/764c1b6bc55548707507a2dd25570483a7216bf4: http2: unsupported scheme

To force http2, I believe I need http.Client.Transport.TLSConfig.NextProtos set to []string{"h2"}.

What else is required?

答案1

得分: 9

你需要使用 https,而不是 http。http2 传输不识别 http 方案。

英文:

You need to use https, not http. The http2 transport doesn't recognize the http scheme.

答案2

得分: 0

HTTP/2.0默认在高度安全的连接上运行。它使用高质量的密码。因此,它只能在HTTPS连接上运行。此外,为了建立HTTPS连接,您还需要启用SSL并安装所需的证书。

英文:

The HTTP/2.0 by default works on highly secured connections. It uses high quality ciphers. So it can only run on HTTPS connections. Moreover, to make HTTPS connections, you also need to have your SSL enabled and have the required certificates installed.

huangapple
  • 本文由 发表于 2015年12月26日 11:23:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/34468231.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定