+-------------------------------------------------------------------
+Wed Oct 22 14:16:33 CEST 2008 - dmacvicar@suse.de
+
+- move anonymous unique id to a private http header
+ X-ZYpp-AnonymousUniqueId (bnc#431571 )
+
-------------------------------------------------------------------
Wed Oct 22 12:58:35 CEST 2008 - ma@suse.de
#include "zypp/base/Gettext.h"
#include "zypp/ZYppCallbacks.h"
+#include "zypp/Target.h"
+#include "zypp/ZYppFactory.h"
+
#include "zypp/media/MediaAria2c.h"
#include "zypp/media/proxyinfo/ProxyInfos.h"
#include "zypp/media/ProxyInfo.h"
return false;
}
+const char *const MediaAria2c::anonymousIdHeader()
+{
+ // we need to add the release and identifier to the
+ // agent string.
+ // The target could be not initialized, and then this information
+ // is not available.
+ Target_Ptr target;
+ // FIXME this has to go away as soon as the target
+ // does not throw when not initialized.
+ try {
+ target = zypp::getZYpp()->target();
+ }
+ catch ( const Exception &e )
+ {
+ // nothing to do
+ }
+
+ static const std::string _value(
+ str::form(
+ "X-ZYpp-AnonymousUniqueId: %s",
+ target ? target->anonymousUniqueId().c_str() : "" )
+ );
+ return _value.c_str();
+}
+
const char *const MediaAria2c::agentString()
{
- static const std::string _value( str::form( "ZYpp %s (with %s)", VERSION, MediaAria2c::_aria2cVersion.c_str() ));
- return _value.c_str();
+ // we need to add the release and identifier to the
+ // agent string.
+ // The target could be not initialized, and then this information
+ // is not available.
+ Target_Ptr target;
+ // FIXME this has to go away as soon as the target
+ // does not throw when not initialized.
+ try {
+ target = zypp::getZYpp()->target();
+ }
+ catch ( const Exception &e )
+ {
+ // nothing to do
+ }
+ static const std::string _value(
+ str::form(
+ "ZYpp %s (aria2c %s) %s"
+ , VERSION
+ , MediaAria2c::_aria2cVersion.c_str()
+ , target ? target->targetDistribution().c_str() : ""
+ )
+ );
+ return _value.c_str();
}
+
MediaAria2c::MediaAria2c( const Url & url_r,
const Pathname & attach_point_hint_r )
: MediaHandler( url_r, attach_point_hint_r,
_args.push_back("--follow-metalink=mem");
_args.push_back("--check-integrity=true");
+ // add the anonymous id.
+ _args.push_back(str::form("--header=\"%s\"", anonymousIdHeader() ));
+
+
if ( next )
ZYPP_THROW(MediaNotSupportedException(_url));
/** The user agent string */
static const char *const agentString();
-
+ /** anonymous id header used to count unique users */
+ static const char *const anonymousIdHeader();
private:
Pathname MediaCurl::_cookieFile = "/var/lib/YaST2/cookies";
+const char *const MediaCurl::anonymousIdHeader()
+{
+ // we need to add the release and identifier to the
+ // agent string.
+ // The target could be not initialized, and then this information
+ // is not available.
+ Target_Ptr target;
+ // FIXME this has to go away as soon as the target
+ // does not throw when not initialized.
+ try {
+ target = zypp::getZYpp()->target();
+ }
+ catch ( const Exception &e )
+ {
+ // nothing to do
+ }
+
+ static const std::string _value(
+ str::form(
+ "X-ZYpp-AnonymousUniqueId: %s",
+ target ? target->anonymousUniqueId().c_str() : "" )
+ );
+ return _value.c_str();
+}
+
const char *const MediaCurl::agentString()
{
// we need to add the release and identifier to the
"ZYpp %s (curl %s) %s"
, VERSION
, curl_version_info(CURLVERSION_NOW)->version
- , target ?
- str::form( " - %s on '%s'"
- , target->anonymousUniqueId().c_str()
- , target->targetDistribution().c_str()
- ).c_str() : ""
+ , target ? target->targetDistribution().c_str() : ""
)
);
return _value.c_str();
disconnectFrom();
ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
}
+
+ // now add the anonymous id header
+ curl_slist *chunk = NULL;
+ chunk = curl_slist_append(chunk, anonymousIdHeader());
+ ret = curl_easy_setopt ( _curl, CURLOPT_HTTPHEADER, chunk );
+ curl_slist_free_all(chunk);
+
+ if ( ret != 0) {
+ disconnectFrom();
+ ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
+ }
+
}
/** The user agent string */
static const char *const agentString();
+ /** anonymous id header used to count unique users */
+ static const char *const anonymousIdHeader();
+
private:
/**
* Return a comma separated list of available authentication methods