From 814f741a281f5d0b48f10e3ae826ff9d92c1f7eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 8 Mar 2015 17:54:07 +0100 Subject: [PATCH] souphttpclientsink: Implement proxy support The properties were there before, but not used anywhere. --- ext/soup/gstsouphttpclientsink.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/ext/soup/gstsouphttpclientsink.c b/ext/soup/gstsouphttpclientsink.c index 784a53f..751aab4 100644 --- a/ext/soup/gstsouphttpclientsink.c +++ b/ext/soup/gstsouphttpclientsink.c @@ -535,11 +535,19 @@ gst_soup_http_client_sink_start (GstBaseSink * sink) g_mutex_unlock (&souphttpsink->mutex); GST_LOG_OBJECT (souphttpsink, "main loop thread running"); - souphttpsink->session = - soup_session_async_new_with_options (SOUP_SESSION_ASYNC_CONTEXT, - souphttpsink->context, SOUP_SESSION_USER_AGENT, - souphttpsink->user_agent, SOUP_SESSION_TIMEOUT, souphttpsink->timeout, - NULL); + if (souphttpsink->proxy == NULL) { + souphttpsink->session = + soup_session_async_new_with_options (SOUP_SESSION_ASYNC_CONTEXT, + souphttpsink->context, SOUP_SESSION_USER_AGENT, + souphttpsink->user_agent, SOUP_SESSION_TIMEOUT, souphttpsink->timeout, + NULL); + } else { + souphttpsink->session = + soup_session_async_new_with_options (SOUP_SESSION_ASYNC_CONTEXT, + souphttpsink->context, SOUP_SESSION_USER_AGENT, + souphttpsink->user_agent, SOUP_SESSION_TIMEOUT, souphttpsink->timeout, + SOUP_SESSION_PROXY_URI, souphttpsink->proxy, NULL); + } g_signal_connect (souphttpsink->session, "authenticate", G_CALLBACK (authenticate), souphttpsink); @@ -793,9 +801,15 @@ authenticate (SoupSession * session, SoupMessage * msg, GstSoupHttpClientSink *souphttpsink = GST_SOUP_HTTP_CLIENT_SINK (user_data); if (!retrying) { - if (souphttpsink->user_id && souphttpsink->user_pw) { - soup_auth_authenticate (auth, - souphttpsink->user_id, souphttpsink->user_pw); + /* First time authentication only, if we fail and are called again with retry true fall through */ + if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) { + if (souphttpsink->user_id && souphttpsink->user_pw) + soup_auth_authenticate (auth, souphttpsink->user_id, + souphttpsink->user_pw); + } else if (msg->status_code == SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED) { + if (souphttpsink->proxy_id && souphttpsink->proxy_pw) + soup_auth_authenticate (auth, souphttpsink->proxy_id, + souphttpsink->proxy_pw); } } } -- 2.7.4