rtspconnection: Use relative URI for non-proxy tunneled requests
Match the section 5.1.2 of the HTTP/1.0 spec by using relative URIs unless we are using a proxy server. Also, send Host header for compatability with HTTP/1.1 and some HTTP/1.0 servers. https://bugzilla.gnome.org/show_bug.cgi?id=758922
This commit is contained in:
parent
65c7bd7a2c
commit
5ac65d9e3a
@ -698,10 +698,15 @@ setup_tunneling (GstRTSPConnection * conn, GTimeVal * timeout, gchar * uri,
|
|||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GSocketConnection *connection;
|
GSocketConnection *connection;
|
||||||
GSocket *socket;
|
GSocket *socket;
|
||||||
gchar *luri = NULL;
|
gchar *connection_uri = NULL;
|
||||||
|
gchar *request_uri = NULL;
|
||||||
|
gchar *host = NULL;
|
||||||
|
|
||||||
url = conn->url;
|
url = conn->url;
|
||||||
|
|
||||||
|
gst_rtsp_url_get_port (url, &url_port);
|
||||||
|
host = g_strdup_printf ("%s:%d", url->host, url_port);
|
||||||
|
|
||||||
/* create a random sessionid */
|
/* create a random sessionid */
|
||||||
for (i = 0; i < TUNNELID_LEN; i++)
|
for (i = 0; i < TUNNELID_LEN; i++)
|
||||||
conn->tunnelid[i] = g_random_int_range ('a', 'z');
|
conn->tunnelid[i] = g_random_int_range ('a', 'z');
|
||||||
@ -718,6 +723,7 @@ setup_tunneling (GstRTSPConnection * conn, GTimeVal * timeout, gchar * uri,
|
|||||||
"application/x-rtsp-tunnelled");
|
"application/x-rtsp-tunnelled");
|
||||||
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CACHE_CONTROL, "no-cache");
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CACHE_CONTROL, "no-cache");
|
||||||
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_PRAGMA, "no-cache");
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_PRAGMA, "no-cache");
|
||||||
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_HOST, host);
|
||||||
add_auth_header (conn, msg);
|
add_auth_header (conn, msg);
|
||||||
|
|
||||||
/* we need to temporarily set conn->tunneled to FALSE to prevent the HTTP
|
/* we need to temporarily set conn->tunneled to FALSE to prevent the HTTP
|
||||||
@ -749,17 +755,20 @@ setup_tunneling (GstRTSPConnection * conn, GTimeVal * timeout, gchar * uri,
|
|||||||
conn->remote_ip = g_strdup (value);
|
conn->remote_ip = g_strdup (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_rtsp_url_get_port (url, &url_port);
|
connection_uri = g_strdup_printf ("http://%s:%d%s%s%s", url->host, url_port,
|
||||||
luri = g_strdup_printf ("http://%s:%d%s%s%s", url->host, url_port,
|
|
||||||
url->abspath, url->query ? "?" : "", url->query ? url->query : "");
|
url->abspath, url->query ? "?" : "", url->query ? url->query : "");
|
||||||
|
|
||||||
/* connect to the host/port */
|
/* connect to the host/port */
|
||||||
if (conn->proxy_host) {
|
if (conn->proxy_host) {
|
||||||
connection = g_socket_client_connect_to_host (conn->client,
|
connection = g_socket_client_connect_to_host (conn->client,
|
||||||
conn->proxy_host, conn->proxy_port, conn->cancellable, &error);
|
conn->proxy_host, conn->proxy_port, conn->cancellable, &error);
|
||||||
|
request_uri = g_strdup (connection_uri);
|
||||||
} else {
|
} else {
|
||||||
connection = g_socket_client_connect_to_uri (conn->client,
|
connection = g_socket_client_connect_to_uri (conn->client,
|
||||||
luri, 0, conn->cancellable, &error);
|
connection_uri, 0, conn->cancellable, &error);
|
||||||
|
request_uri =
|
||||||
|
g_strdup_printf ("%s%s%s", url->abspath,
|
||||||
|
url->query ? "?" : "", url->query ? url->query : "");
|
||||||
}
|
}
|
||||||
if (connection == NULL)
|
if (connection == NULL)
|
||||||
goto connect_failed;
|
goto connect_failed;
|
||||||
@ -781,8 +790,8 @@ setup_tunneling (GstRTSPConnection * conn, GTimeVal * timeout, gchar * uri,
|
|||||||
conn->control_stream = NULL;
|
conn->control_stream = NULL;
|
||||||
|
|
||||||
/* create the POST request for the write connection */
|
/* create the POST request for the write connection */
|
||||||
GST_RTSP_CHECK (gst_rtsp_message_new_request (&msg, GST_RTSP_POST, luri),
|
GST_RTSP_CHECK (gst_rtsp_message_new_request (&msg, GST_RTSP_POST,
|
||||||
no_message);
|
request_uri), no_message);
|
||||||
msg->type = GST_RTSP_MESSAGE_HTTP_REQUEST;
|
msg->type = GST_RTSP_MESSAGE_HTTP_REQUEST;
|
||||||
|
|
||||||
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_X_SESSIONCOOKIE,
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_X_SESSIONCOOKIE,
|
||||||
@ -794,6 +803,7 @@ setup_tunneling (GstRTSPConnection * conn, GTimeVal * timeout, gchar * uri,
|
|||||||
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_EXPIRES,
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_EXPIRES,
|
||||||
"Sun, 9 Jan 1972 00:00:00 GMT");
|
"Sun, 9 Jan 1972 00:00:00 GMT");
|
||||||
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CONTENT_LENGTH, "32767");
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CONTENT_LENGTH, "32767");
|
||||||
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_HOST, host);
|
||||||
add_auth_header (conn, msg);
|
add_auth_header (conn, msg);
|
||||||
|
|
||||||
/* we need to temporarily set conn->tunneled to FALSE to prevent the HTTP
|
/* we need to temporarily set conn->tunneled to FALSE to prevent the HTTP
|
||||||
@ -804,7 +814,9 @@ setup_tunneling (GstRTSPConnection * conn, GTimeVal * timeout, gchar * uri,
|
|||||||
conn->tunneled = TRUE;
|
conn->tunneled = TRUE;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
g_free (luri);
|
g_free (connection_uri);
|
||||||
|
g_free (request_uri);
|
||||||
|
g_free (host);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@ -876,7 +888,7 @@ gst_rtsp_connection_connect_with_response (GstRTSPConnection * conn,
|
|||||||
GSocketConnection *connection;
|
GSocketConnection *connection;
|
||||||
GSocket *socket;
|
GSocket *socket;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gchar *uri, *remote_ip;
|
gchar *connection_uri, *request_uri, *remote_ip;
|
||||||
GstClockTime to;
|
GstClockTime to;
|
||||||
guint16 url_port;
|
guint16 url_port;
|
||||||
GstRTSPUrl *url;
|
GstRTSPUrl *url;
|
||||||
@ -894,18 +906,23 @@ gst_rtsp_connection_connect_with_response (GstRTSPConnection * conn,
|
|||||||
gst_rtsp_url_get_port (url, &url_port);
|
gst_rtsp_url_get_port (url, &url_port);
|
||||||
|
|
||||||
if (conn->tunneled) {
|
if (conn->tunneled) {
|
||||||
uri = g_strdup_printf ("http://%s:%d%s%s%s", url->host, url_port,
|
connection_uri = g_strdup_printf ("http://%s:%d%s%s%s", url->host, url_port,
|
||||||
url->abspath, url->query ? "?" : "", url->query ? url->query : "");
|
url->abspath, url->query ? "?" : "", url->query ? url->query : "");
|
||||||
} else {
|
} else {
|
||||||
uri = gst_rtsp_url_get_request_uri (url);
|
connection_uri = gst_rtsp_url_get_request_uri (url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->proxy_host) {
|
if (conn->proxy_host) {
|
||||||
connection = g_socket_client_connect_to_host (conn->client,
|
connection = g_socket_client_connect_to_host (conn->client,
|
||||||
conn->proxy_host, conn->proxy_port, conn->cancellable, &error);
|
conn->proxy_host, conn->proxy_port, conn->cancellable, &error);
|
||||||
|
request_uri = g_strdup (connection_uri);
|
||||||
} else {
|
} else {
|
||||||
connection = g_socket_client_connect_to_uri (conn->client,
|
connection = g_socket_client_connect_to_uri (conn->client,
|
||||||
uri, url_port, conn->cancellable, &error);
|
connection_uri, url_port, conn->cancellable, &error);
|
||||||
|
|
||||||
|
/* use the relative component of the uri for non-proxy connections */
|
||||||
|
request_uri = g_strdup_printf ("%s%s%s", url->abspath,
|
||||||
|
url->query ? "?" : "", url->query ? url->query : "");
|
||||||
}
|
}
|
||||||
if (connection == NULL)
|
if (connection == NULL)
|
||||||
goto connect_failed;
|
goto connect_failed;
|
||||||
@ -928,11 +945,12 @@ gst_rtsp_connection_connect_with_response (GstRTSPConnection * conn,
|
|||||||
conn->control_stream = NULL;
|
conn->control_stream = NULL;
|
||||||
|
|
||||||
if (conn->tunneled) {
|
if (conn->tunneled) {
|
||||||
res = setup_tunneling (conn, timeout, uri, response);
|
res = setup_tunneling (conn, timeout, request_uri, response);
|
||||||
if (res != GST_RTSP_OK)
|
if (res != GST_RTSP_OK)
|
||||||
goto tunneling_failed;
|
goto tunneling_failed;
|
||||||
}
|
}
|
||||||
g_free (uri);
|
g_free (connection_uri);
|
||||||
|
g_free (request_uri);
|
||||||
|
|
||||||
return GST_RTSP_OK;
|
return GST_RTSP_OK;
|
||||||
|
|
||||||
@ -941,7 +959,8 @@ connect_failed:
|
|||||||
{
|
{
|
||||||
GST_ERROR ("failed to connect: %s", error->message);
|
GST_ERROR ("failed to connect: %s", error->message);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
g_free (uri);
|
g_free (connection_uri);
|
||||||
|
g_free (request_uri);
|
||||||
return GST_RTSP_ERROR;
|
return GST_RTSP_ERROR;
|
||||||
}
|
}
|
||||||
remote_address_failed:
|
remote_address_failed:
|
||||||
@ -949,13 +968,15 @@ remote_address_failed:
|
|||||||
GST_ERROR ("failed to connect: %s", error->message);
|
GST_ERROR ("failed to connect: %s", error->message);
|
||||||
g_object_unref (connection);
|
g_object_unref (connection);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
g_free (uri);
|
g_free (connection_uri);
|
||||||
|
g_free (request_uri);
|
||||||
return GST_RTSP_ERROR;
|
return GST_RTSP_ERROR;
|
||||||
}
|
}
|
||||||
tunneling_failed:
|
tunneling_failed:
|
||||||
{
|
{
|
||||||
GST_ERROR ("failed to setup tunneling");
|
GST_ERROR ("failed to setup tunneling");
|
||||||
g_free (uri);
|
g_free (connection_uri);
|
||||||
|
g_free (request_uri);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user