From 07e7235dc47e4e9326bb7b563f25883609f4dbdf Mon Sep 17 00:00:00 2001 From: Saxon Date: Sun, 28 Apr 2019 00:53:47 +0930 Subject: [PATCH] protocol/rtsp: using string literals for request methods --- protocol/rtsp/client.go | 8 ++++---- protocol/rtsp/rtsp.go | 8 -------- protocol/rtsp/rtsp_test.go | 8 ++++---- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/protocol/rtsp/client.go b/protocol/rtsp/client.go index 39a261ce..133adf38 100644 --- a/protocol/rtsp/client.go +++ b/protocol/rtsp/client.go @@ -61,7 +61,7 @@ func NewClient(addr string) (*Client, error) { // Describe forms and sends an RTSP request of method DESCRIBE to the RTSP server. func (c *Client) Describe() (*Response, error) { - req, err := NewRequest(describe, c.nextCSeq(), c.url, nil) + req, err := NewRequest("DESCRIBE", c.nextCSeq(), c.url, nil) if err != nil { return nil, err } @@ -71,7 +71,7 @@ func (c *Client) Describe() (*Response, error) { // Options forms and sends an RTSP request of method OPTIONS to the RTSP server. func (c *Client) Options() (*Response, error) { - req, err := NewRequest(options, c.nextCSeq(), c.url, nil) + req, err := NewRequest("OPTIONS", c.nextCSeq(), c.url, nil) if err != nil { return nil, err } @@ -85,7 +85,7 @@ func (c *Client) Setup(track, transport string) (*Response, error) { return nil, err } - req, err := NewRequest(setup, c.nextCSeq(), url, nil) + req, err := NewRequest("SETUP", c.nextCSeq(), url, nil) if err != nil { return nil, err } @@ -102,7 +102,7 @@ func (c *Client) Setup(track, transport string) (*Response, error) { // Play forms and sends an RTSP request of method PLAY to the RTSP server func (c *Client) Play() (*Response, error) { - req, err := NewRequest(play, c.nextCSeq(), c.url, nil) + req, err := NewRequest("PLAY", c.nextCSeq(), c.url, nil) if err != nil { return nil, err } diff --git a/protocol/rtsp/rtsp.go b/protocol/rtsp/rtsp.go index d88a3206..e9981330 100644 --- a/protocol/rtsp/rtsp.go +++ b/protocol/rtsp/rtsp.go @@ -69,14 +69,6 @@ import ( "strings" ) -// RTSP methods. -const ( - describe = "DESCRIBE" - options = "OPTIONS" - play = "PLAY" - setup = "SETUP" -) - // Minimum response size to be considered valid. const minResponse = 2 diff --git a/protocol/rtsp/rtsp_test.go b/protocol/rtsp/rtsp_test.go index 3cd70d57..5fd9a212 100644 --- a/protocol/rtsp/rtsp_test.go +++ b/protocol/rtsp/rtsp_test.go @@ -58,7 +58,7 @@ func TestMethods(t *testing.T) { }{ { method: func(c *Client) (*Response, error) { - req, err := NewRequest(describe, c.nextCSeq(), url, nil) + req, err := NewRequest("DESCRIBE", c.nextCSeq(), url, nil) if err != nil { return nil, err } @@ -79,7 +79,7 @@ func TestMethods(t *testing.T) { }, { method: func(c *Client) (*Response, error) { - req, err := NewRequest(options, c.nextCSeq(), url, nil) + req, err := NewRequest("OPTIONS", c.nextCSeq(), url, nil) if err != nil { return nil, err } @@ -102,7 +102,7 @@ func TestMethods(t *testing.T) { return nil, err } - req, err := NewRequest(setup, c.nextCSeq(), u, nil) + req, err := NewRequest("SETUP", c.nextCSeq(), u, nil) if err != nil { return nil, err } @@ -126,7 +126,7 @@ func TestMethods(t *testing.T) { }, { method: func(c *Client) (*Response, error) { - req, err := NewRequest(play, c.nextCSeq(), url, nil) + req, err := NewRequest("PLAY", c.nextCSeq(), url, nil) if err != nil { return nil, err }