// this is similar to httputil.NewSingleHostReverseProxy except it passes along basic auth func NewSingleHostReverseProxy(target *url.URL, timeout time.Duration) *httputil.ReverseProxy { director := func(req *http.Request) { req.URL.Scheme = target.Scheme req.URL.Host = target.Host if target.User != nil { passwd, _ := target.User.Password() req.SetBasicAuth(target.User.Username(), passwd) } } return &httputil.ReverseProxy{ Director: director, Transport: http_api.NewDeadlineTransport(timeout), } }
func init() { httpclient = &http.Client{Transport: http_api.NewDeadlineTransport(*httpTimeout)} userAgent = fmt.Sprintf("nsq_to_http v%s", version.Binary) }