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

Method httpCloudHandler

ais/proxy.go:2772–2801  ·  view source on GitHub ↗

http reverse-proxy handler, to handle unmodified requests (not to confuse with p.rproxy)

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

2770// http reverse-proxy handler, to handle unmodified requests
2771// (not to confuse with p.rproxy)
2772func (p *proxy) httpCloudHandler(w http.ResponseWriter, r *http.Request) {
2773 if !p.ClusterStartedWithRetry() {
2774 w.WriteHeader(http.StatusServiceUnavailable)
2775 return
2776 }
2777 if r.URL.Scheme == "" {
2778 p.writeErrURL(w, r)
2779 return
2780 }
2781 baseURL := r.URL.Scheme + "://" + r.URL.Host
2782 if glog.FastV(4, glog.SmoduleAIS) {
2783 glog.Infof("[HTTP CLOUD] RevProxy handler for: %s -> %s", baseURL, r.URL.Path)
2784 }
2785 if r.Method == http.MethodGet || r.Method == http.MethodHead {
2786 // bck.IsHTTP()
2787 hbo := cmn.NewHTTPObj(r.URL)
2788 q := r.URL.Query()
2789 q.Set(apc.QparamOrigURL, r.URL.String())
2790 q.Set(apc.QparamProvider, apc.ProviderHTTP)
2791 r.URL.Path = apc.URLPathObjects.Join(hbo.Bck.Name, hbo.ObjName)
2792 r.URL.RawQuery = q.Encode()
2793 if r.Method == http.MethodGet {
2794 p.httpobjget(w, r, hbo.OrigURLBck)
2795 } else {
2796 p.httpobjhead(w, r, hbo.OrigURLBck)
2797 }
2798 return
2799 }
2800 p.writeErrf(w, r, "%q provider doesn't support %q", apc.ProviderHTTP, r.Method)
2801}
2802
2803/////////////////
2804// METASYNC RX //

Callers

nothing calls this directly

Calls 12

httpobjgetMethod · 0.95
httpobjheadMethod · 0.95
FastVFunction · 0.92
InfofFunction · 0.92
NewHTTPObjFunction · 0.92
WriteHeaderMethod · 0.80
writeErrURLMethod · 0.80
JoinMethod · 0.80
writeErrfMethod · 0.80
SetMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected