GNOME Bugzilla – Bug 774768
rtsp: duplicated content-length error.
Last modified: 2016-11-21 11:22:55 UTC
Created attachment 340386 [details] a patch for this bug There is duplicated rtsp content-length error. The specific deivce disconnects rtsp connection due to this bug. So I checked tcpdump and found this bug. If you add content-length header to message using "gst_rtsp_message_add_header", the content length is duplicated twice. You can check it in tcpdump rtsp text. for example, RTSP/1.0 200 OK CSeq: 2 Content-Type: text/parameters Content-Length: 645 Date: Thu, 01 Jan 1970 00:02:27 GMT Content-Length: 645
Created attachment 340388 [details] [review] a patch for this bug. update the patch.
Where is it added the first time? How can this be reproduced?
in message_to_string 1) first /* append headers */ gst_rtsp_message_append_headers (message, str); 2) second len = g_strdup_printf ("%d", message->body_size); g_string_append_printf (str, "%s: %s\r\n", gst_rtsp_header_as_text (GST_RTSP_HDR_CONTENT_LENGTH), len); I think, first time is not necessary. So I removed the content-length in message. You can reproduce as following : 1. set body 2. set content length 3. send the rtsp message Capture tcpdump for the packet and check. you can check the duplicated issue in real rtsp text
Who was originally setting the content length though, if GstRTSPConnection always sets it by itself anyway?
I can not answer your question exactly. I think..if gstrtspconnection sets the length using body length, it can handle wrong conten length that is set from user. The gstreamer developers can set the content length as below. gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CONTENT_LENGTH, legnth);
Yes but who does set it manually in your case? That code should be fixed as the connection will already do that.
Yes We've set the content length in manually. I will also remove to set the length because it's unnecessary.
Which code does that?
It is our custom rtsp src plugin using rtspconnection.
In current status, Any person using gstrtsp sets rtsp body and content-length in menually. The length is duplicated in real packet..
I see, that's a bug in your code then :)
The patch is rejected.. Is it wrong ?
Hm.. I think the content length should be set once in real packet, even though we set the length in menually.
The bug is in your code. You're not supposed to add the Content-Length header yourself but GstRTSPConnection is doing that.
Or am I misunderstanding what you mean?
I can not expect to set content-Length by gstrtspconnection in automatically. Thank you for response.
Why can't you expect GstRTSPConnection to do that?
We add many fields to rtsp header such as GST_RTSP_HDR_PUBLIC, GST_RTSP_HDR_USER_AGENT, GST_RTSP_HDR_CONTENT_TYPE, GST_RTSP_HDR_REQUIRE and etc.. So we set GST_RTSP_HDR_CONTENT_LENGTH also. We can not expect that duplicated in real packet.
You mean the documentation should make clear that you must not set Content-Length because the connection already does that for you? The connection is also setting various other headers for you already, especially for authentication.
Yes. It needs some guide or handle the exception case in automatically. In my just opinion, second way will be better. So I made the patch..