title: CURLOPT_USERPWD seems to be ignored
body: <p>Usinglibcurl version: 7.19.7</p>
  
  <p>[Sorry for the verbosity of this message]</p>
  
  <p>I am having problems getting simple Basic
  authentication to work with libcurl.
  I have a server setup to provide a password
  protected piece of data: url is in the code.</p>
  
  <p>I took the simple.c libcurl example
  and modified it to set CURLOPT_USERPWD
  (code below). When I run it, I get the
  curl verbose output below [html styles elided].</p>
  
  <p>Notes:</p>
  
  <ol>
  <li> if I paste the url into a browser, it will
     ask for the user and password and if supplied
     it returns the data correctly. I assume this
     means that the server's claim of being
     unauthorized is bogus (correct?).
  <li> If I put the "username:passwd@" into the url, I appear
     to get the same result.
  </ol>
  
  <p>Anyone see the problem?</p>
  
  <p>=Dennis Heimbigner
  Unidata</p>
  
  <h2>Curl verbose Output</h2>
  
  <pre><code>* About to connect() to utmea.enea.it port 8080 (#0)
  *   Trying 192.107.77.41... * connected
  * Connected to utmea.enea.it (192.107.77.41) port 8080 (#0)
  &gt; &gt; GET /thredds/dodsC/UNIDATA_passwd/head_out.nc.dds HTTP/1.1
  Host: utmea.enea.it:8080
  Accept: */*
  
  &lt; HTTP/1.1 307 Temporary Redirect
  &lt; Server: Apache-Coyote/1.1
  &lt; Last-Modified: 
  &lt; Set-Cookie: JSESSIONID=BEC21BBB6DD954B7BD60F1BED1414A8E; Path=/thredds/; HttpOnly
  &lt; Location: http://utmea.enea.it:8080/thredds/restrictedAccess/accediUNIDATA
  &lt; Content-Length: 0
  &lt; Date: Tue, 12 Nov 2013 18:49:00 GMT
  &lt; 
  * Connection #0 to host utmea.enea.it left intact
  * Issue another request to this URL: 'http://utmea.enea.it:8080/thredds/restrictedAccess/accediUNIDATA'
  * Re-using existing connection! (#0) with host utmea.enea.it
  * Connected to utmea.enea.it (192.107.77.41) port 8080 (#0)
  &gt; &gt; GET /thredds/restrictedAccess/accediUNIDATA HTTP/1.1
  Host: utmea.enea.it:8080
  Accept: */*
  
  &lt; HTTP/1.1 401 Unauthorized
  &lt; Server: Apache-Coyote/1.1
  &lt; Cache-Control: private
  &lt; Expires: Thu, 01 Jan 1970 01:00:00 CET
  &lt; WWW-Authenticate: Basic realm="THREDDS Data Server"
  &lt; Content-Type: text/html;charset=utf-8
  &lt; Content-Length: 951
  &lt; Date: Tue, 12 Nov 2013 18:49:00 GMT
  &lt; 
  * Ignoring the response-body
  * Connection #0 to host utmea.enea.it left intact
  * Issue another request to this URL: 'http://utmea.enea.it:8080/thredds/restrictedAccess/accediUNIDATA'
  * Re-using existing connection! (#0) with host utmea.enea.it
  * Connected to utmea.enea.it (192.107.77.41) port 8080 (#0)
  * Server auth using Basic with user 'ticket'
  &gt; &gt; GET /thredds/restrictedAccess/accediUNIDATA HTTP/1.1
  Authorization: Basic dGlja2V0OnRpY2tldDE=
  Host: utmea.enea.it:8080
  Accept: */*
  
  &lt; HTTP/1.1 401 Unauthorized
  &lt; Server: Apache-Coyote/1.1
  &lt; Cache-Control: private
  &lt; Expires: Thu, 01 Jan 1970 01:00:00 CET
  &lt; Set-Cookie: JSESSIONID=E0E3AC390A39C786C3CFD139F601D8B8; Path=/thredds/; HttpOnly
  &lt; Content-Type: text/html;charset=utf-8
  &lt; Content-Length: 1027
  &lt; Date: Tue, 12 Nov 2013 18:49:00 GMT
  &lt; 
  &lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/7.0.35 - Error report&lt;/title&gt;
  &lt;style&gt;...&lt;/style&gt;
  &lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 401 - Not authorized to access this dataset.&lt;/h1&gt;
  ... not authorized to access this dataset.&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;This request requires HTTP authentication.&lt;/u&gt;&lt;/p&gt;...&lt;h3&gt;Apache Tomcat/7.0.35&lt;/h3&gt;&lt;/body&gt;&lt;/ht* Connection #0 to host utmea.enea.it left intact
  * Closing connection #0
  </code></pre>
  
  <h2>Modified simple.c</h2>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;curl/curl.h&gt;
  
  int main(void)
  {
    CURL *curl;
    CURLcode res;
  
    curl = curl_easy_init();
    if(curl) {
      curl_easy_setopt(curl, CURLOPT_URL, "http://utmea.enea.it:8080/thredds/dodsC/UNIDATA_passwd/head_out.nc.dds");
      curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
      curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
      curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
      curl_easy_setopt(curl, CURLOPT_USERPWD, "ticket:ticket1");
  
      /* Perform the request, res will get the return code */
      res = curl_easy_perform(curl);
      /* Check for errors */
      if(res != CURLE_OK)
        fprintf(stderr, "curl_easy_perform() failed: %s\n",
                curl_easy_strerror(res));
  
      /* always cleanup */
      curl_easy_cleanup(curl);
    }
    return 0;
  }
  </code></pre>