Golang net/http.Transport type examples

package net/http

Golang net/http.Transport type usage examples

Example 1:

  t := &http.Transport{}
  t.RegisterProtocol("file", http.NewFileTransport(http.Dir("/")))
  c := &http.Client{Transport: t}
  res, err := c.Get("file:///etc/passwd")

Example 2:

 var httpClient = &http.Client{Transport: &transport{
 t: http.Transport{
 Dial: timeoutDial,
 ResponseHeaderTimeout: *requestTimeout / 2,
 }}}

Reference :

http://golang.org/pkg/net/http/#Transport

Advertisement