MCPcopy
hub / github.com/NVIDIA/aistore / redirectURL

Method redirectURL

ais/proxy.go:1897–1928  ·  view source on GitHub ↗
(r *http.Request, si *cluster.Snode, ts time.Time, netName string)

Source from the content-addressed store, hash-verified

1895}
1896
1897func (p *proxy) redirectURL(r *http.Request, si *cluster.Snode, ts time.Time, netName string) (redirect string) {
1898 var (
1899 nodeURL string
1900 query = url.Values{}
1901 )
1902 if p.si.LocalNet == nil {
1903 nodeURL = si.URL(cmn.NetPublic)
1904 } else {
1905 var local bool
1906 remote := r.RemoteAddr
1907 if colon := strings.Index(remote, ":"); colon != -1 {
1908 remote = remote[:colon]
1909 }
1910 if ip := net.ParseIP(remote); ip != nil {
1911 local = p.si.LocalNet.Contains(ip)
1912 }
1913 if local {
1914 nodeURL = si.URL(netName)
1915 } else {
1916 nodeURL = si.URL(cmn.NetPublic)
1917 }
1918 }
1919 redirect = nodeURL + r.URL.Path + "?"
1920 if r.URL.RawQuery != "" {
1921 redirect += r.URL.RawQuery + "&"
1922 }
1923
1924 query.Set(apc.QparamProxyID, p.si.ID())
1925 query.Set(apc.QparamUnixTime, cos.UnixNano2S(ts.UnixNano()))
1926 redirect += query.Encode()
1927 return
1928}
1929
1930func initAsyncQuery(bck *cmn.Bck, msg *apc.BckSummMsg, newTaskID string) (bool, url.Values) {
1931 isNew := msg.UUID == ""

Callers 11

httpobjgetMethod · 0.95
httpobjputMethod · 0.95
httpobjdeleteMethod · 0.95
httpobjheadMethod · 0.95
httpobjpatchMethod · 0.95
objMvMethod · 0.95
copyObjS3Method · 0.95
directPutObjS3Method · 0.95
getObjS3Method · 0.95
delObjS3Method · 0.95
redirectToICMethod · 0.80

Calls 5

UnixNano2SFunction · 0.92
SetMethod · 0.65
IDMethod · 0.65
URLMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected