Set the agent string for HTTP and HTTPS
authorJiri Srain <jsrain@suse.cz>
Tue, 21 Feb 2006 15:39:57 +0000 (15:39 +0000)
committerJiri Srain <jsrain@suse.cz>
Tue, 21 Feb 2006 15:39:57 +0000 (15:39 +0000)
zypp/media/MediaCurl.cc
zypp/media/MediaCurl.h

index 0176639..365edee 100644 (file)
@@ -37,6 +37,8 @@ Pathname MediaCurl::_cookieFile = "/var/lib/YaST2/cookies";
 
 bool MediaCurl::_globalInit = false;
 
+std::string _agent = "Novell ZYPP Installer";
+
 ///////////////////////////////////////////////////////////////////
 
 static inline void escape( string & str_r,
@@ -160,6 +162,10 @@ void MediaCurl::attachTo (bool next)
     if ( ret != 0) {
       ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
     }
+    ret = curl_easy_setopt ( _curl, CURLOPT_USERAGENT, _agent.c_str() );
+    if ( ret != 0) {
+      ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
+    }
   }
 
   if ( _url.getScheme() == "https" ) {
@@ -175,6 +181,10 @@ void MediaCurl::attachTo (bool next)
     if ( ret != 0 ) {
       ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
     }
+    ret = curl_easy_setopt ( _curl, CURLOPT_USERAGENT, _agent.c_str() );
+    if ( ret != 0) {
+      ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
+    }
   }
 
 
index 7659979..53ea1b5 100644 (file)
@@ -89,6 +89,8 @@ class MediaCurl : public MediaHandler {
     bool _connected;
 
     static bool _globalInit;
+
+    static std::string _agent;
 };
 
 ///////////////////////////////////////////////////////////////////