mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 15:46:51 +08:00
support basic authentication
This commit is contained in:
@@ -3,6 +3,7 @@ package gortsplib
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -40,3 +41,22 @@ func ReadHeaderAuth(in string) (*HeaderAuth, error) {
|
||||
|
||||
return ha, nil
|
||||
}
|
||||
|
||||
// Write encodes an Authenticate or a WWW-Authenticate header.
|
||||
func (ha *HeaderAuth) Write() string {
|
||||
ret := ha.Prefix + " "
|
||||
|
||||
var sortedKeys []string
|
||||
for key := range ha.Values {
|
||||
sortedKeys = append(sortedKeys, key)
|
||||
}
|
||||
sort.Strings(sortedKeys)
|
||||
|
||||
var tmp []string
|
||||
for _, key := range sortedKeys {
|
||||
tmp = append(tmp, key+"=\""+ha.Values[key]+"\"")
|
||||
}
|
||||
ret += strings.Join(tmp, ", ")
|
||||
|
||||
return ret
|
||||
}
|
||||
|
Reference in New Issue
Block a user