diff --git a/protocol/rtsp/rtsp.go b/protocol/rtsp/rtsp.go index 0140b569..029a57f1 100644 --- a/protocol/rtsp/rtsp.go +++ b/protocol/rtsp/rtsp.go @@ -43,7 +43,7 @@ import ( // Minimum response size to be considered valid in bytes. const minResponse = 12 -var errSmallResponse = errors.New("response too small") +var errInvalidResponse = errors.New("invalid response") // Request describes an RTSP request. type Request struct { @@ -132,12 +132,8 @@ func ReadResponse(r io.Reader) (*Response, error) { } s := scanner.Text() - if len(s) < minResponse { - return nil, errSmallResponse - } - - if s[:5] != "RTSP/" { - return nil, errors.New("invalid response") + if len(s) < minResponse || s[:5] != "RTSP/" { + return nil, errInvalidResponse } resp.Proto = "RTSP" diff --git a/protocol/rtsp/rtsp_test.go b/protocol/rtsp/rtsp_test.go index dcdf7148..f1a2257b 100644 --- a/protocol/rtsp/rtsp_test.go +++ b/protocol/rtsp/rtsp_test.go @@ -213,7 +213,7 @@ func TestMethods(t *testing.T) { for i, test := range tests { _, err = test.method(clt) - if err != nil && err != io.EOF && err != errSmallResponse { + if err != nil && err != io.EOF && err != errInvalidResponse { clientErr <- errors.New(fmt.Sprintf("error request for: %v err: %v", i, err)) } }