From 69dc07881c8fa1c088200d605ed131a30e5b5661 Mon Sep 17 00:00:00 2001 From: Aaron Shumway Date: Thu, 20 Apr 2017 11:05:33 -0600 Subject: [PATCH] use basic auth or digest auth, not both --- format/rtsp/client.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/format/rtsp/client.go b/format/rtsp/client.go index c9fca83..8534f7a 100644 --- a/format/rtsp/client.go +++ b/format/rtsp/client.go @@ -350,16 +350,18 @@ func (self *Client) handle401(res *Response) (err error) { password, _ = self.url.User.Password() self.authHeaders = func(method string) []string { - headers := []string{ - fmt.Sprintf(`Authorization: Basic %s`, base64.StdEncoding.EncodeToString([]byte(username+":"+password))), - } - if nonce != "" { + var headers []string + if nonce == "" { + headers = []string{ + fmt.Sprintf(`Authorization: Basic %s`, base64.StdEncoding.EncodeToString([]byte(username+":"+password))), + } + } else { hs1 := md5hash(username + ":" + realm + ":" + password) hs2 := md5hash(method + ":" + self.requestUri) response := md5hash(hs1 + ":" + nonce + ":" + hs2) - headers = append(headers, fmt.Sprintf( + headers = []string{fmt.Sprintf( `Authorization: Digest username="%s", realm="%s", nonce="%s", uri="%s", response="%s"`, - username, realm, nonce, self.requestUri, response)) + username, realm, nonce, self.requestUri, response)} } return headers }