mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 23:26:54 +08:00
do not treat generic bytes as strings into errors
This commit is contained in:
@@ -75,10 +75,10 @@ func (req *Request) Read(rb *bufio.Reader) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
proto := string(byts[:len(byts)-1])
|
proto := byts[:len(byts)-1]
|
||||||
|
|
||||||
if proto != rtspProtocol10 {
|
if string(proto) != rtspProtocol10 {
|
||||||
return fmt.Errorf("expected '%s', got '%s'", rtspProtocol10, proto)
|
return fmt.Errorf("expected '%s', got %v", rtspProtocol10, proto)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = readByteEqual(rb, '\n')
|
err = readByteEqual(rb, '\n')
|
||||||
|
@@ -187,7 +187,7 @@ func TestRequestReadErrors(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"empty protocol",
|
"empty protocol",
|
||||||
[]byte("GET rtsp://testing123 \r\n"),
|
[]byte("GET rtsp://testing123 \r\n"),
|
||||||
"expected 'RTSP/1.0', got ''",
|
"expected 'RTSP/1.0', got []",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid URL",
|
"invalid URL",
|
||||||
@@ -197,7 +197,7 @@ func TestRequestReadErrors(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"invalid protocol",
|
"invalid protocol",
|
||||||
[]byte("GET rtsp://testing123 RTSP/2.0\r\n"),
|
[]byte("GET rtsp://testing123 RTSP/2.0\r\n"),
|
||||||
"expected 'RTSP/1.0', got 'RTSP/2.0'",
|
"expected 'RTSP/1.0', got [82 84 83 80 47 50 46 48]",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid header",
|
"invalid header",
|
||||||
|
@@ -139,10 +139,10 @@ func (res *Response) Read(rb *bufio.Reader) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
proto := string(byts[:len(byts)-1])
|
proto := byts[:len(byts)-1]
|
||||||
|
|
||||||
if proto != rtspProtocol10 {
|
if string(proto) != rtspProtocol10 {
|
||||||
return fmt.Errorf("expected '%s', got '%s'", rtspProtocol10, proto)
|
return fmt.Errorf("expected '%s', got %v", rtspProtocol10, proto)
|
||||||
}
|
}
|
||||||
|
|
||||||
byts, err = readBytesLimited(rb, ' ', 4)
|
byts, err = readBytesLimited(rb, ' ', 4)
|
||||||
|
@@ -139,7 +139,7 @@ func TestResponseReadErrors(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"invalid protocol",
|
"invalid protocol",
|
||||||
[]byte("RTSP/2.0 200 OK\r\n"),
|
[]byte("RTSP/2.0 200 OK\r\n"),
|
||||||
"expected 'RTSP/1.0', got 'RTSP/2.0'",
|
"expected 'RTSP/1.0', got [82 84 83 80 47 50 46 48]",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code too long",
|
"code too long",
|
||||||
|
Reference in New Issue
Block a user