From a59817d492b3a32cbc889392fa8e9a75f70e7955 Mon Sep 17 00:00:00 2001
From: unknown <jhollinger@.gdrs.com>
Date: Fri, 27 May 2011 15:45:04 -0400
Subject: [PATCH 1/2] Curl_rtsp: Added call to Curl_http_output_auth() to set proxyuserpwd or userpwd in connectdata struct if authentication is enabled. Also modified call to Curl_add_bufferf() to output proxyuserpwd and userpwd from the connectdata struct if they are set.

---
 lib/rtsp.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/lib/rtsp.c b/lib/rtsp.c
index 14f430c..7df5de9 100644
--- a/lib/rtsp.c
+++ b/lib/rtsp.c
@@ -214,6 +214,8 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done)
   const char *p_stream_uri = NULL;
   const char *p_transport = NULL;
   const char *p_uagent = NULL;
+  const char *p_proxyuserpwd = NULL;
+  const char *p_userpwd = NULL;
 
   *done = TRUE;
 
@@ -305,9 +307,6 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done)
     return CURLE_BAD_FUNCTION_ARGUMENT;
   }
 
-  /* TODO: auth? */
-  /* TODO: proxy? */
-
   /* Stream URI. Default to server '*' if not specified */
   if(data->set.str[STRING_RTSP_STREAM_URI]) {
     p_stream_uri = data->set.str[STRING_RTSP_STREAM_URI];
@@ -371,6 +370,14 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done)
     p_uagent = conn->allocptr.uagent;
   }
 
+  /* setup the authentication headers */
+  result = Curl_http_output_auth(conn, p_request, p_stream_uri, FALSE);
+  if(result)
+    return result;
+
+  p_proxyuserpwd = conn->allocptr.proxyuserpwd;
+  p_userpwd = conn->allocptr.userpwd;
+
   /* Referrer */
   Curl_safefree(conn->allocptr.ref);
   if(data->change.referer && !Curl_checkheaders(data, "Referer:"))
@@ -444,13 +451,25 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done)
                             "%s" /* range */
                             "%s" /* referrer */
                             "%s" /* user-agent */
+                            "%s" /* proxyuserpwd */
+                            "%s" /* userpwd */
                             ,
                             p_transport ? p_transport : "",
                             p_accept ? p_accept : "",
                             p_accept_encoding ? p_accept_encoding : "",
                             p_range ? p_range : "",
                             p_referrer ? p_referrer : "",
-                            p_uagent ? p_uagent : "");
+                            p_uagent ? p_uagent : "",
+                            p_proxyuserpwd ? p_proxyuserpwd : "",
+                            p_userpwd ? p_userpwd : "");
+
+  /*
+   * Free userpwd now --- cannot reuse this for Negotiate and possibly NTLM
+   * with basic and digest, it will be freed anyway by the next request
+   */
+  Curl_safefree (conn->allocptr.userpwd);
+  conn->allocptr.userpwd = NULL;
+
   if(result)
     return result;
 
-- 
1.7.4.msysgit.0

