/* 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);
GstRTSPClient *client;
GstRTSPMessage request = { 0, };
gchar *str;
+ GstRTSPConnection *conn;
+ GSocket *sock;
+ GError *error = NULL;
client = gst_rtsp_client_new ();
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);
}