mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
client: allow absolute path in requests
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=711689
This commit is contained in:
parent
8ce453d97d
commit
adc02db975
2 changed files with 66 additions and 2 deletions
|
@ -1934,8 +1934,34 @@ handle_request (GstRTSPClient * client, GstRTSPMessage * request)
|
|||
/* we always try to parse the url first */
|
||||
if (strcmp (uristr, "*") == 0) {
|
||||
/* special case where we have * as uri, keep uri = NULL */
|
||||
} else if (gst_rtsp_url_parse (uristr, &uri) != GST_RTSP_OK)
|
||||
goto bad_request;
|
||||
} else if (gst_rtsp_url_parse (uristr, &uri) != GST_RTSP_OK) {
|
||||
/* check if the uristr is an absolute path <=> scheme and host information
|
||||
* is missing */
|
||||
gchar *scheme;
|
||||
|
||||
scheme = g_uri_parse_scheme (uristr);
|
||||
if (scheme == NULL && g_str_has_prefix (uristr, "/")) {
|
||||
gchar *absolute_uristr = NULL;
|
||||
|
||||
GST_WARNING_OBJECT (client, "request doesn't contain absolute url");
|
||||
if (priv->server_ip == NULL) {
|
||||
GST_WARNING_OBJECT (client, "host information missing");
|
||||
goto bad_request;
|
||||
}
|
||||
|
||||
absolute_uristr = g_strdup_printf ("rtsp://%s%s", priv->server_ip, uristr);
|
||||
|
||||
GST_DEBUG_OBJECT (client, "absolute url: %s", absolute_uristr);
|
||||
if (gst_rtsp_url_parse (absolute_uristr, &uri) != GST_RTSP_OK) {
|
||||
g_free (absolute_uristr);
|
||||
goto bad_request;
|
||||
}
|
||||
g_free (absolute_uristr);
|
||||
} else {
|
||||
g_free (scheme);
|
||||
goto bad_request;
|
||||
}
|
||||
}
|
||||
|
||||
/* get the session if there is any */
|
||||
res = gst_rtsp_message_get_header (request, GST_RTSP_HDR_SESSION, &sessid, 0);
|
||||
|
|
|
@ -155,6 +155,9 @@ GST_START_TEST (test_request)
|
|||
GstRTSPClient *client;
|
||||
GstRTSPMessage request = { 0, };
|
||||
gchar *str;
|
||||
GstRTSPConnection *conn;
|
||||
GSocket *sock;
|
||||
GError *error = NULL;
|
||||
|
||||
client = gst_rtsp_client_new ();
|
||||
|
||||
|
@ -185,6 +188,41 @@ GST_START_TEST (test_request)
|
|||
|
||||
gst_rtsp_message_unset (&request);
|
||||
|
||||
/* OPTIONS with an absolute path instead of an absolute url */
|
||||
/* set host information */
|
||||
sock = g_socket_new (G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_STREAM,
|
||||
G_SOCKET_PROTOCOL_TCP, &error);
|
||||
g_assert_no_error (error);
|
||||
gst_rtsp_connection_create_from_socket (sock, "localhost", 444, NULL, &conn);
|
||||
fail_unless (gst_rtsp_client_set_connection (client, conn));
|
||||
g_object_unref (sock);
|
||||
|
||||
fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_OPTIONS,
|
||||
"/test") == GST_RTSP_OK);
|
||||
str = g_strdup_printf ("%d", cseq);
|
||||
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_CSEQ, str);
|
||||
g_free (str);
|
||||
|
||||
gst_rtsp_client_set_send_func (client, test_response_200, NULL, NULL);
|
||||
fail_unless (gst_rtsp_client_handle_message (client,
|
||||
&request) == GST_RTSP_OK);
|
||||
gst_rtsp_message_unset (&request);
|
||||
|
||||
/* OPTIONS with an absolute path instead of an absolute url with invalid
|
||||
* host information */
|
||||
g_object_unref (client);
|
||||
client = gst_rtsp_client_new ();
|
||||
fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_OPTIONS,
|
||||
"/test") == GST_RTSP_OK);
|
||||
str = g_strdup_printf ("%d", cseq);
|
||||
gst_rtsp_message_add_header (&request, GST_RTSP_HDR_CSEQ, str);
|
||||
g_free (str);
|
||||
|
||||
gst_rtsp_client_set_send_func (client, test_response_400, NULL, NULL);
|
||||
fail_unless (gst_rtsp_client_handle_message (client,
|
||||
&request) == GST_RTSP_OK);
|
||||
gst_rtsp_message_unset (&request);
|
||||
|
||||
g_object_unref (client);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue