Golang net / http / transport代理CONNECT方法头支持

时间:2016-09-19 16:00:54

标签: go

Golang的包net / http / transport可以在

中自动设置<script> $(document).ready(function () { $('#companies').DataTable( { "ajax": { url: "/Company/GetCompanyGrid", type: "GET", dataType: "json" },"columns": [ { "data": "Id" }, { "data": "RegNo" }, { "data": "Name" }, { "data": "Industry" }, { "data": "Size" }, { "data": "LineOfDefence" }, { "data": "Address" }, { "data": "Logo" }, { "data": null }, ] }); }); </script> 标头
Proxy-Authorization

func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (*persistConn, error)

但我需要将X-Header提交给代理服务器。我如何自定义传输CONNECT方法请求标头?

net/http/transport

1 个答案:

答案 0 :(得分:0)

怎么样:

// ...
request, err := http.NewRequest("GET", "https://www.google.com", nil)
if err != nil {
  // do something
}
// add header here.
request.Header.Add("X-Header", "xxx")

response, err := client.Do(request)
if err != nil {
  // do something
}
// ...