英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论