golang/go

net/http: document outgoing Host header origin in more places

Open

#34,124 创建于 2019年9月5日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)Go (19,008 fork)batch import
DocumentationNeedsFixhelp wanted

仓库指标

Star
 (133,883 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

What did you do?

https://play.golang.org/p/O5Y6dEi_hqx

What did you expect to see?

I expected to see that setting a Host: header actually sends hosts and sets req.Host map[Accept-Encoding:[gzip] Host:[example.com] User-Agent:[My Test User Agent 1.1]]

What did you see instead?

I see that it just sets Hosts from url and uses req.Host if exists. map[Accept-Encoding:[gzip] Host:[127.0.0.1:2] User-Agent:[My Test User Agent 1.1]]

I see some closed issues, but I have a few more words about it, It is documented that we need to set .Host to send host header and there are few more headers that calculated in request.write but for example User-Agent is being overwritten but it does not do this for Host. https://github.com/golang/go/blob/master/src/net/http/request.go#L553 on this comment we see that it says

// Find the target host. Prefer the Host: header, but if that
	// is not given, use the host from the request URL.

but it does not even look at host header.

贡献者指南