Handle case where no auth is sent to rpcserver.

This commit is contained in:
John C. Vernaleo 2013-10-03 08:12:18 -04:00
parent fd0679acdd
commit 35c95f0a36

View file

@ -45,7 +45,8 @@ func (s *rpcServer) Start() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
login := s.username + ":" + s.password
auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login))
if r.Header["Authorization"][0] == auth {
authhdr := r.Header["Authorization"]
if len(authhdr) > 0 && authhdr[0] == auth {
jsonRPCRead(w, r, s)
} else {
log.Warnf("[RPCS] Auth failure.")