[banshee] MusicBrainz: Allow specifying a UserAgent



commit 53370ce3130bb379767656d59cb7e65cb1647bed
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed May 4 16:03:32 2011 -0500

    MusicBrainz: Allow specifying a UserAgent
    
    MB now requires a UserAgent to be set.  This change will let Banshee set
    one.

 .../MusicBrainz/MusicBrainz/MusicBrainzObject.cs   |    3 ++-
 .../MusicBrainz/MusicBrainz/MusicBrainzService.cs  |    2 ++
 2 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/src/Libraries/MusicBrainz/MusicBrainz/MusicBrainzObject.cs b/src/Libraries/MusicBrainz/MusicBrainz/MusicBrainzObject.cs
index 1a2732a..d83261e 100644
--- a/src/Libraries/MusicBrainz/MusicBrainz/MusicBrainzObject.cs
+++ b/src/Libraries/MusicBrainz/MusicBrainz/MusicBrainzObject.cs
@@ -389,7 +389,8 @@ namespace MusicBrainz
             if (min_interval > time)
                 Thread.Sleep ((min_interval - time).Milliseconds);
 
-            WebRequest request = WebRequest.Create (url);
+            var request = WebRequest.Create (url) as HttpWebRequest;
+            request.UserAgent = MusicBrainzService.UserAgent;
             if (cache_implemented == null) {
                 try {
                     request.CachePolicy = MusicBrainzService.CachePolicy;
diff --git a/src/Libraries/MusicBrainz/MusicBrainz/MusicBrainzService.cs b/src/Libraries/MusicBrainz/MusicBrainz/MusicBrainzService.cs
index 5e860db..f868e2b 100644
--- a/src/Libraries/MusicBrainz/MusicBrainz/MusicBrainzService.cs
+++ b/src/Libraries/MusicBrainz/MusicBrainz/MusicBrainzService.cs
@@ -36,6 +36,8 @@ namespace MusicBrainz
             }
         }
 
+        public static string UserAgent { get; set; }
+
         static RequestCachePolicy cache_policy;
         public static RequestCachePolicy CachePolicy {
             get { return cache_policy; }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]