00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
00013 #define ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
00014
00015 #include <string>
00016 #include <list>
00017
00018 #include "zypp/Url.h"
00019 #include "zypp/base/String.h"
00020 #include "zypp/media/ProxyInfo.h"
00021
00022 namespace zypp {
00023 namespace media {
00024
00025 struct ProxyInfo::Impl
00026 {
00028 Impl()
00029 {}
00030
00032 virtual ~Impl()
00033 {}
00034
00035 public:
00037 virtual bool enabled() const = 0;
00039 virtual std::string proxy(const std::string & prorocol_r) const = 0;
00041 virtual ProxyInfo::NoProxyList noProxy() const = 0;
00043 virtual ProxyInfo::NoProxyIterator noProxyBegin() const = 0;
00045 virtual ProxyInfo::NoProxyIterator noProxyEnd() const = 0;
00046
00048 bool useProxyFor( const Url & url_r ) const
00049 {
00050 if ( ! enabled() )
00051 return false;
00052
00053 ProxyInfo::NoProxyList noproxy( noProxy() );
00054 if ( noproxy.size() == 1 && noproxy.front() == "*" )
00055 return false;
00056
00057
00058
00059
00060
00061 std::string host( str::toLower( url_r.getHost() ) );
00062 for_( it, noproxy.begin(), noproxy.end() )
00063 {
00064 std::string pattern( str::toLower( (*it)[0] == '.' ? it->c_str() + 1 : it->c_str() ) );
00065 if ( str::hasSuffix( host, pattern )
00066 && ( host.size() == pattern.size()
00067 || host[host.size()-pattern.size()-1] == '.' ) )
00068 return false;
00069 }
00070 return true;
00071 }
00072
00073 public:
00075 static shared_ptr<Impl> _nullimpl;
00076 };
00077
00078
00080
00081 }
00082 }
00083
00084 #endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H