Skip to content

Commit

Permalink
use basic auth or digest auth, not both
Browse files Browse the repository at this point in the history
  • Loading branch information
acls committed Apr 20, 2017
1 parent 4b82a8c commit 69dc078
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions format/rtsp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 69dc078

Please sign in to comment.