rtsp: ignore \n and \r as the first line

Be more forgiving for bad servers and ignore \r and \n when we are looking for
the response/request line.

See #608417
This commit is contained in:
Wim Taymans 2010-01-29 16:34:44 +01:00
parent be037e0dc8
commit 30fd219e63

View file

@ -1834,22 +1834,31 @@ build_next (GstRTSPBuilder * builder, GstRTSPMessage * message,
while (TRUE) { while (TRUE) {
switch (builder->state) { switch (builder->state) {
case STATE_START: case STATE_START:
{
guint8 c;
builder->offset = 0; builder->offset = 0;
res = res =
read_bytes (conn, (guint8 *) builder->buffer, &builder->offset, 1); read_bytes (conn, (guint8 *) builder->buffer, &builder->offset, 1);
if (res != GST_RTSP_OK) if (res != GST_RTSP_OK)
goto done; goto done;
c = builder->buffer[0];
/* we have 1 bytes now and we can see if this is a data message or /* we have 1 bytes now and we can see if this is a data message or
* not */ * not */
if (builder->buffer[0] == '$') { if (c == '$') {
/* data message, prepare for the header */ /* data message, prepare for the header */
builder->state = STATE_DATA_HEADER; builder->state = STATE_DATA_HEADER;
} else if (c == '\n' || c == '\r') {
/* skip \n and \r */
builder->offset = 0;
} else { } else {
builder->line = 0; builder->line = 0;
builder->state = STATE_READ_LINES; builder->state = STATE_READ_LINES;
} }
break; break;
}
case STATE_DATA_HEADER: case STATE_DATA_HEADER:
{ {
res = res =