mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 23:52:46 +08:00
rename Response Status into StatusMessage
This commit is contained in:
@@ -61,7 +61,7 @@ func NewAuthClient(header []string, user string, pass string) (*AuthClient, erro
|
||||
}
|
||||
|
||||
// GenerateHeader generates an Authorization Header that allows to authenticate a request with
|
||||
// the given method and path.
|
||||
// the given method and url.
|
||||
func (ac *AuthClient) GenerateHeader(method Method, ur *url.URL) []string {
|
||||
ha1 := md5Hex(ac.user + ":" + ac.realm + ":" + ac.pass)
|
||||
ha2 := md5Hex(string(method) + ":" + ur.String())
|
||||
|
12
response.go
12
response.go
@@ -62,7 +62,7 @@ const (
|
||||
// Response is a RTSP response.
|
||||
type Response struct {
|
||||
StatusCode StatusCode
|
||||
Status string
|
||||
StatusMessage string
|
||||
Header Header
|
||||
Content []byte
|
||||
}
|
||||
@@ -96,9 +96,9 @@ func readResponse(br *bufio.Reader) (*Response, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res.Status = string(byts[:len(byts)-1])
|
||||
res.StatusMessage = string(byts[:len(byts)-1])
|
||||
|
||||
if len(res.Status) == 0 {
|
||||
if len(res.StatusMessage) == 0 {
|
||||
return nil, fmt.Errorf("empty status")
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ func readResponse(br *bufio.Reader) (*Response, error) {
|
||||
}
|
||||
|
||||
func (res *Response) write(bw *bufio.Writer) error {
|
||||
if res.Status == "" {
|
||||
if res.StatusMessage == "" {
|
||||
if status, ok := statusMessages[res.StatusCode]; ok {
|
||||
res.Status = status
|
||||
res.StatusMessage = status
|
||||
}
|
||||
}
|
||||
|
||||
_, err := bw.Write([]byte(_RTSP_PROTO + " " + strconv.FormatInt(int64(res.StatusCode), 10) + " " + res.Status + "\r\n"))
|
||||
_, err := bw.Write([]byte(_RTSP_PROTO + " " + strconv.FormatInt(int64(res.StatusCode), 10) + " " + res.StatusMessage + "\r\n"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ var casesResponse = []struct {
|
||||
),
|
||||
&Response{
|
||||
StatusCode: StatusOK,
|
||||
Status: "OK",
|
||||
StatusMessage: "OK",
|
||||
Header: Header{
|
||||
"CSeq": []string{"1"},
|
||||
"Public": []string{"DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE"},
|
||||
@@ -41,7 +41,7 @@ var casesResponse = []struct {
|
||||
),
|
||||
&Response{
|
||||
StatusCode: StatusOK,
|
||||
Status: "OK",
|
||||
StatusMessage: "OK",
|
||||
Header: Header{
|
||||
"CSeq": []string{"2"},
|
||||
"Session": []string{"645252166"},
|
||||
@@ -80,7 +80,7 @@ var casesResponse = []struct {
|
||||
),
|
||||
&Response{
|
||||
StatusCode: 200,
|
||||
Status: "OK",
|
||||
StatusMessage: "OK",
|
||||
Header: Header{
|
||||
"Content-Base": []string{"rtsp://example.com/media.mp4"},
|
||||
"Content-Length": []string{"444"},
|
||||
|
Reference in New Issue
Block a user