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
|
// 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 {
|
func (ac *AuthClient) GenerateHeader(method Method, ur *url.URL) []string {
|
||||||
ha1 := md5Hex(ac.user + ":" + ac.realm + ":" + ac.pass)
|
ha1 := md5Hex(ac.user + ":" + ac.realm + ":" + ac.pass)
|
||||||
ha2 := md5Hex(string(method) + ":" + ur.String())
|
ha2 := md5Hex(string(method) + ":" + ur.String())
|
||||||
|
18
response.go
18
response.go
@@ -61,10 +61,10 @@ const (
|
|||||||
|
|
||||||
// Response is a RTSP response.
|
// Response is a RTSP response.
|
||||||
type Response struct {
|
type Response struct {
|
||||||
StatusCode StatusCode
|
StatusCode StatusCode
|
||||||
Status string
|
StatusMessage string
|
||||||
Header Header
|
Header Header
|
||||||
Content []byte
|
Content []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func readResponse(br *bufio.Reader) (*Response, error) {
|
func readResponse(br *bufio.Reader) (*Response, error) {
|
||||||
@@ -96,9 +96,9 @@ func readResponse(br *bufio.Reader) (*Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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")
|
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 {
|
func (res *Response) write(bw *bufio.Writer) error {
|
||||||
if res.Status == "" {
|
if res.StatusMessage == "" {
|
||||||
if status, ok := statusMessages[res.StatusCode]; ok {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ var casesResponse = []struct {
|
|||||||
"\r\n",
|
"\r\n",
|
||||||
),
|
),
|
||||||
&Response{
|
&Response{
|
||||||
StatusCode: StatusOK,
|
StatusCode: StatusOK,
|
||||||
Status: "OK",
|
StatusMessage: "OK",
|
||||||
Header: Header{
|
Header: Header{
|
||||||
"CSeq": []string{"1"},
|
"CSeq": []string{"1"},
|
||||||
"Public": []string{"DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE"},
|
"Public": []string{"DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE"},
|
||||||
@@ -40,8 +40,8 @@ var casesResponse = []struct {
|
|||||||
"\r\n",
|
"\r\n",
|
||||||
),
|
),
|
||||||
&Response{
|
&Response{
|
||||||
StatusCode: StatusOK,
|
StatusCode: StatusOK,
|
||||||
Status: "OK",
|
StatusMessage: "OK",
|
||||||
Header: Header{
|
Header: Header{
|
||||||
"CSeq": []string{"2"},
|
"CSeq": []string{"2"},
|
||||||
"Session": []string{"645252166"},
|
"Session": []string{"645252166"},
|
||||||
@@ -79,8 +79,8 @@ var casesResponse = []struct {
|
|||||||
"a=StreamName:string;\"hinted audio track\"\n",
|
"a=StreamName:string;\"hinted audio track\"\n",
|
||||||
),
|
),
|
||||||
&Response{
|
&Response{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
Status: "OK",
|
StatusMessage: "OK",
|
||||||
Header: Header{
|
Header: Header{
|
||||||
"Content-Base": []string{"rtsp://example.com/media.mp4"},
|
"Content-Base": []string{"rtsp://example.com/media.mp4"},
|
||||||
"Content-Length": []string{"444"},
|
"Content-Length": []string{"444"},
|
||||||
|
Reference in New Issue
Block a user