From 27aa34d4aed3cbc1778423dbd3563285d6de626a Mon Sep 17 00:00:00 2001
From: Ian Zimmerman <itz@buug.org>
Date: Sat, 29 Jan 2011 08:43:30 +0100
Subject: [PATCH] input/curl: enable CURLOPT_NETRC

I wanted mpd to play a mp3 stream from a music website.  The stream is
only available to subscribers, which restriction is enforced through
normal http authentication.  However, the URL I get from the website
is not the final URL of the stream, but a generic URL which points to
the real one through a redirect (code 301).  Thus, I cannot predict
the final URL, and so I cannot use the username:password hack to force
the authentication, and mpd (libcurl on mpds behalf) fails to grab the
stream.

libcurl allows the option CURLOPT_NETRC to be set and then the
credentials can be stored in the good old .netrc file (in this case it
would be ~mpd/.netrc, of course).  But mpd doesn't set this option.  I
think it should.
---
 NEWS                          | 1 +
 src/input/curl_input_plugin.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/NEWS b/NEWS
index ae0eba1b7..5c9693ee5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 ver 0.17 (2010/??/??)
 * input:
   - cdio_paranoia: new input plugin to play audio CDs
+  - curl: enable CURLOPT_NETRC
 * decoder:
   - mpg123: implement seeking
 * output:
diff --git a/src/input/curl_input_plugin.c b/src/input/curl_input_plugin.c
index ae645bddf..873874e12 100644
--- a/src/input/curl_input_plugin.c
+++ b/src/input/curl_input_plugin.c
@@ -647,6 +647,7 @@ input_curl_easy_init(struct input_curl *c, GError **error_r)
 	curl_easy_setopt(c->easy, CURLOPT_WRITEDATA, c);
 	curl_easy_setopt(c->easy, CURLOPT_HTTP200ALIASES, http_200_aliases);
 	curl_easy_setopt(c->easy, CURLOPT_FOLLOWLOCATION, 1);
+	curl_easy_setopt(c->easy, CURLOPT_NETRC, 1);
 	curl_easy_setopt(c->easy, CURLOPT_MAXREDIRS, 5);
 	curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, true);
 	curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error);