MCPcopy Index your code
hub / github.com/cubefs/cubefs / proxy

Method proxy

authnode/http_server.go:147–173  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

145}
146
147func (m *Server) proxy(w http.ResponseWriter, r *http.Request) {
148 if m.cluster.PKIKey.EnableHTTPS {
149 var (
150 plaintext []byte
151 err error
152 res []byte
153 jobj proto.HTTPAuthReply
154 )
155 target := "https://" + m.leaderInfo.addr + r.URL.Path
156 if plaintext, err = m.extractClientReqInfo(r); err != nil {
157 sendErrReply(w, r, &proto.HTTPAuthReply{Code: proto.ErrCodeParamError, Msg: err.Error()})
158 return
159 }
160 res, err = proto.SendBytes(m.authProxy.client, target, plaintext)
161 if err != nil {
162 sendErrReply(w, r, &proto.HTTPAuthReply{Code: proto.ErrCodeAuthReqRedirectError, Msg: "[proxy] failed: " + err.Error()})
163 return
164 }
165 if jobj, err = proto.ParseAuthReply(res); err != nil {
166 sendErrReply(w, r, &proto.HTTPAuthReply{Code: proto.ErrCodeAuthReqRedirectError, Msg: "Target Server failed: " + err.Error()})
167 return
168 }
169 sendOkReply(w, r, newSuccessHTTPAuthReply(jobj.Data))
170 } else {
171 m.authProxy.reverseProxy.ServeHTTP(w, r)
172 }
173}

Callers 1

Calls 8

extractClientReqInfoMethod · 0.95
SendBytesFunction · 0.92
ParseAuthReplyFunction · 0.92
newSuccessHTTPAuthReplyFunction · 0.85
sendErrReplyFunction · 0.70
sendOkReplyFunction · 0.70
ErrorMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected