[gnome-boxes] downloader: Force "wget" as user-agent in SoupSession



commit 5eec37e5dc77f1640c0f94217bfa898db8cbcf8b
Author: Fabiano FidĂȘncio <fidencio redhat com>
Date:   Tue Mar 24 00:00:25 2020 +0100

    downloader: Force "wget" as user-agent in SoupSession
    
    Spoiler alert, it'll sound insane ... because it is insane. Some servers
    treat libsoup user-agent differently than how they treat wget
    user-agent.
    
    After a talk with Patrick Griffis, he mentioned that:
    "I imagine there isn't too much of a problem pretending to be wget. I would
    guess the assumption by these services is 'A CLI tool is downloading us and
    not a browser' rather than 'wget has unique behavior'.".
    
    Knowing that, let's force "wget" as user-agent on our side.
    
    https://gitlab.gnome.org/GNOME/gnome-boxes/-/issues/463
    
    Signed-off-by: Fabiano FidĂȘncio <fidencio redhat com>

 src/downloader.vala | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/downloader.vala b/src/downloader.vala
index e69aaaa4..8b30ab52 100644
--- a/src/downloader.vala
+++ b/src/downloader.vala
@@ -61,8 +61,9 @@ private Downloader () {
         if (Environment.get_variable ("SOUP_DEBUG") != null)
             session.add_feature (new Soup.Logger (Soup.LoggerLogLevel.HEADERS, -1));
 
-        var user_agent = get_user_agent ();
-        session.user_agent = user_agent;
+        // As some websites redirect based on UA, lets force wget user-agent so the
+        // website assumes it's a CLI tool downloading the file.
+        session.user_agent = "Wget/1.0";
     }
 
     /**


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