From 35c95f0a36dc8168f9b74c831fd42804cbfb7d9f Mon Sep 17 00:00:00 2001
From: "John C. Vernaleo" <jcv@conformal.com>
Date: Thu, 3 Oct 2013 08:12:18 -0400
Subject: [PATCH] Handle case where no auth is sent to rpcserver.

---
 rpcserver.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rpcserver.go b/rpcserver.go
index ea25eb86..d50ed41c 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -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.")