httpunix.go
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
	if req.URL == nil {
		return nil, errors.New("http+unix: nil Request.URL")
	}
	if req.URL.Scheme != Scheme {
		return nil, errors.New("unsupported protocol scheme: " + req.URL.Scheme)
	}
	if req.URL.Host == "" {
		return nil, errors.New("http+unix: no Host in request URL")
	}
	t.mu.Lock()
	path, ok := t.loc[req.URL.Host]
	t.mu.Unlock()
	if !ok {
		return nil, errors.New("unknown location: " + req.Host)
	}

	c, err := net.DialTimeout("unix", path, t.DialTimeout)
	if err != nil {
		return nil, err
	}
	r := bufio.NewReader(c)
	if t.RequestTimeout > 0 {
		c.SetWriteDeadline(time.Now().Add(t.RequestTimeout))
	}
	if err := req.Write(c); err != nil {
		return nil, err
	}
	if t.ResponseHeaderTimeout > 0 {
		c.SetReadDeadline(time.Now().Add(t.ResponseHeaderTimeout))
	}
	resp, err := http.ReadResponse(r, req)
	return resp, err
}
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
	if req.URL == nil {
		return nil, errors.New("http+unix: nil Request.URL")
	}
	if req.URL.Scheme != Scheme {
		return nil, errors.New("unsupported protocol scheme: " + req.URL.Scheme)
	}
	if req.URL.Host == "" {
		return nil, errors.New("http+unix: no Host in request URL")
	}
	t.mu.Lock()
	path, ok := t.loc[req.URL.Host]
	t.mu.Unlock()
	if !ok {
		return nil, errors.New("unknown location: " + req.Host)
	}

	c, err := net.DialTimeout("unix", path, t.DialTimeout)
	if err != nil {
		return nil, err
	}
	r := bufio.NewReader(c)
	if t.RequestTimeout > 0 {
		c.SetWriteDeadline(time.Now().Add(t.RequestTimeout))
	}
	if err := req.Write(c); err != nil {
		return nil, err
	}
	if t.ResponseHeaderTimeout > 0 {
		c.SetReadDeadline(time.Now().Add(t.ResponseHeaderTimeout))
	}
	resp, err := http.ReadResponse(r, req)
	return resp, err
}
func ( t * Transport ) RoundTrip ( req * http . Request ) ( * http . Response , error ) { if req . URL == nil { return nil , errors . New ( " " ) } if req . URL . Scheme != Scheme { return nil , errors . New ( " " + req . URL . Scheme ) } if req . URL . Host == " " { return nil , errors . New ( " " ) } t . mu . Lock ( ) path , ok := t . loc [ req . URL . Host ] t . mu . Unlock ( ) if ! ok { return nil , errors . New ( " " + req . Host ) } c , err := net . DialTimeout ( " " , path , t . DialTimeout ) if err != nil { return nil , err } r := bufio . NewReader ( c ) if t . RequestTimeout > 0 { c . SetWriteDeadline ( time . Now ( ) . Add ( t . RequestTimeout ) ) } if err := req . Write ( c ) ; err != nil { return nil , err } if t . ResponseHeaderTimeout > 0 { c . SetReadDeadline ( time . Now ( ) . Add ( t . ResponseHeaderTimeout ) ) } resp , err := http . ReadResponse ( r , req ) return resp , err }
// RoundTrip executes a single HTTP transaction. See
// net/http.RoundTripper.
RoundTrip executes a single HTTP transaction . See net / http . RoundTripper .