/* * Constructor. * In this implementation newProxy is ignored, since proxy configuration * is taken from the WinInet subsystem. * * @param url the url where messages will be sent with sendMessage() * @param proxy proxy information or NULL if no proxy should be used */ CurlTransportAgent::CurlTransportAgent(URL& newURL, Proxy& newProxy, unsigned int maxResponseTimeout) : TransportAgent(newURL, newProxy, maxResponseTimeout){ easyhandle = CurlInit::easy_init(); if (easyhandle) { curl_easy_setopt(easyhandle, CURLOPT_DEBUGFUNCTION, debugCallback); curl_easy_setopt(easyhandle, CURLOPT_VERBOSE, LOG.getLevel() ? true : false); curl_easy_setopt(easyhandle, CURLOPT_NOPROGRESS, true); curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, receiveData); curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, this); curl_easy_setopt(easyhandle, CURLOPT_READFUNCTION, sendData); curl_easy_setopt(easyhandle, CURLOPT_READDATA, this); curl_easy_setopt(easyhandle, CURLOPT_ERRORBUFFER, this->curlerrortxt ); curl_easy_setopt(easyhandle, CURLOPT_AUTOREFERER, true); curl_easy_setopt(easyhandle, CURLOPT_FOLLOWLOCATION, true); if (proxy.host[0]) { curl_easy_setopt(easyhandle, CURLOPT_PROXY, proxy.host); if (proxy.port) { curl_easy_setopt(easyhandle, CURLOPT_PROXYPORT, proxy.port); } if (proxy.user) { sprintf(proxyauth, "%s:%s", proxy.user, proxy.password); curl_easy_setopt(easyhandle, CURLOPT_PROXYUSERPWD, proxyauth); } } } setUserAgent("Funambol POSIX SyncML client"); }
void AccessConfig::assign(const AccessConfig& s) { setUsername (s.getUsername() ); setPassword (s.getPassword() ); setSyncURL (s.getSyncURL() ); setProxyHost(s.getProxyHost()); setProxyPort(s.getProxyPort()); setUserAgent(s.getUserAgent()); setProxyUsername(s.getProxyUsername()); setProxyPassword(s.getProxyPassword()); setBeginSync(s.getBeginSync()); setEndSync(s.getEndSync()); setFirstTimeSyncMode(s.getFirstTimeSyncMode()); setServerAuthRequired(s.getServerAuthRequired()); setClientAuthType(s.getClientAuthType()); setServerAuthType(s.getServerAuthType()); setServerPWD(s.getServerPWD()); setServerID(s.getServerID()); setServerNonce(s.getServerNonce()); setClientNonce(s.getClientNonce()); setMaxMsgSize(s.getMaxMsgSize()); setReadBufferSize(s.getReadBufferSize()); setCheckConn(s.getCheckConn()); setResponseTimeout(s.getResponseTimeout()); setCompression(s.getCompression()); dirty = s.getDirty(); }
BassPlayer::BassPlayer(QWidget * parent) : IPlayer(parent), chan(0), openChannelWatcher(0) { if (HIWORD(BASS_GetVersion()) != BASSVERSION) throw "An incorrect version of BASS.DLL was loaded"; if (HIWORD(BASS_FX_GetVersion()) != BASSVERSION) throw "An incorrect version of BASS_FX.DLL was loaded"; // BASS_SetVolume(1); initOutputDevice(identifyOutputDevice()); loadPlugins(); setUserAgent(DEFAULT_AGENT); }
void HTTPTransportAgent::setConfig(SyncConfig &config) { if (config.getUseProxy()) { setProxy(config.getProxyHost()); UserIdentity identity = config.getProxyUser(); Credentials cred = IdentityProviderCredentials(identity, config.getProxyPassword()); setProxyAuth(cred.m_username, cred.m_password); } setUserAgent(config.getUserAgent()); setSSL(config.findSSLServerCertificate(), config.getSSLVerifyServer(), config.getSSLVerifyHost()); }
Target EIOS_RequestTarget(char *initarg) { int len; if (initarg != 0 && (len=strlen(initarg)) > 0) { initargs args; char *buffer = new char[len+1]; int ida=0,idb=0,idx; while (ida < len && (buffer[idb++]=initarg[ida++]) != ','); buffer[idb-1]=0; if (initarg[ida++] != '"') return NULL; args.version = atoi(&buffer[0]); if (args.version == 0) { args.root = &buffer[idb]; while (ida < len && (buffer[idb++]=initarg[ida++]) != '"'); buffer[idb-1]=0; if (initarg[ida++] != ',') return NULL; if (initarg[ida++] != '"') return NULL; args.params = &buffer[idb]; while (ida < len && (buffer[idb++]=initarg[ida++]) != '"'); buffer[idb-1]=0; if (initarg[ida++] != ',') return NULL; idx = idb; while (ida < len && (buffer[idb++]=initarg[ida++]) != ','); buffer[idb-1]=0; if (initarg[ida-1] != ',') return NULL; args.width = atoi(&buffer[idx]); idx = idb; while (ida < len && (buffer[idb++]=initarg[ida++]) != ','); buffer[idb-1]=0; if (initarg[ida-1] != ',') return NULL; args.height = atoi(&buffer[idx]); if (initarg[ida++] != '"') return NULL; args.initseq = &buffer[idb]; while (ida < len && (buffer[idb++]=initarg[ida++]) != '"'); buffer[idb-1]=0; if (initarg[ida++] != ',') return NULL; idx = idb; while (ida < len && (buffer[idb++]=initarg[ida++]) != ','); buffer[idb-1]=0; if (initarg[ida-1] != ',') return NULL; args.maxmem = atoi(&buffer[idx]); if (initarg[ida++] != '"') return NULL; args.jvmpath = &buffer[idb]; while (ida < len && (buffer[idb++]=initarg[ida++]) != '"'); buffer[idb-1]=0; if (initarg[ida++] != ',') return NULL;if (initarg[ida++] != '"') return NULL; args.useragent = &buffer[idb]; while (ida < len && (buffer[idb++]=initarg[ida++]) != '"'); buffer[idb-1]=0; if (args.maxmem != -1) setMaxJVMMem(args.maxmem); if (strlen(args.jvmpath) > 0) setJVMPath(args.jvmpath); if (strlen(args.useragent) > 0) setUserAgent(args.useragent); setup(args.root,args.params,args.width,args.height,args.initseq); return (void*)1; //Smart only supports one target at a time, this is just a success response. } } return NULL; //This result signifies a failure }
WeekLister::WeekLister(bool cache) : _cache(cache), _weeklist(nullptr), _http(_io) { Configure &config = *(Configure::getInstance()); _url_weeklist = config[constant::config::urls][constant::config::chart].asString(); _regex_weeklist = config[constant::config::regexs][constant::config::chart].asString(); if (_url_weeklist.empty() || _regex_weeklist.empty()) { throw std::logic_error(constant::error::configure_error); } std::string user_agent = config[constant::config::useragent].asString(); setUserAgent(user_agent, &_http); _weeklist = new ListCollection; }
CategoryMusicLister::CategoryMusicLister(unsigned int catid, bool cache) : _catid(catid), _cache(cache), _musiclist(nullptr), _http(_io) { Configure &config = *(Configure::getInstance()); _url_catsong = config[constant::config::urls][constant::config::catsong].asString(); _regex_catsong = config[constant::config::regexs][constant::config::catsong].asString(); if (_url_catsong.empty() || _regex_catsong.empty()) { throw std::logic_error(constant::error::configure_error); } std::string user_agent = config[constant::config::useragent].asString(); setUserAgent(user_agent, &_http); _musiclist = new ListCollection; }
void QtWebKitWebPage::optionChanged(const QString &option, const QVariant &value) { if (option == QLatin1String("Network/UserAgent")) { if (m_isGlobalUserAgent) { setUserAgent(value.toString(), NetworkManagerFactory::getUserAgent(value.toString()).value, false); } } else if (option == QLatin1String("Content/ZoomTextOnly")) { settings()->setAttribute(QWebSettings::ZoomTextOnly, value.toBool()); } else if (option.startsWith(QLatin1String("Content/"))) { settings()->setUserStyleSheetUrl(QUrl(QLatin1String("data:text/css;charset=utf-8;base64,") + QString(QStringLiteral("html {color: %1;} a {color: %2;} a:visited {color: %3;}").arg(SettingsManager::getValue(QLatin1String("Content/TextColor")).toString()).arg(SettingsManager::getValue(QLatin1String("Content/LinkColor")).toString()).arg(SettingsManager::getValue(QLatin1String("Content/VisitedLinkColor")).toString()).toUtf8().toBase64()))); } }
void QtWebKitWebPage::optionChanged(const QString &option, const QVariant &value) { if (option == QLatin1String("Network/UserAgent")) { if (m_isGlobalUserAgent) { setUserAgent(value.toString(), NetworkManagerFactory::getUserAgent(value.toString()).value, false); } } else if (option == QLatin1String("Content/ZoomTextOnly")) { settings()->setAttribute(QWebSettings::ZoomTextOnly, value.toBool()); } else if (option.startsWith(QLatin1String("Content/"))) { updatePageStyleSheets(); } }
void WinLauncher::setUserAgent(UINT menuID) { if (!webView()) return; _bstr_t customUserAgent; switch (menuID) { case IDM_UA_DEFAULT: // Set to null user agent break; case IDM_UA_SAFARI_8_0: customUserAgent = L"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25"; break; case IDM_UA_SAFARI_IOS_8_IPHONE: customUserAgent = L"Mozilla/5.0 (iPhone; CPU OS 8_1 like Mac OS X) AppleWebKit/601.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B403 Safari/600.1.4"; break; case IDM_UA_SAFARI_IOS_8_IPAD: customUserAgent = L"Mozilla/5.0 (iPad; CPU OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B403 Safari/600.1.4"; break; case IDM_UA_IE_11: customUserAgent = L"Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko"; break; case IDM_UA_CHROME_MAC: customUserAgent = L"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31"; break; case IDM_UA_CHROME_WIN: customUserAgent = L"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"; break; case IDM_UA_FIREFOX_MAC: customUserAgent = L"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0"; break; case IDM_UA_FIREFOX_WIN: customUserAgent = L"Mozilla/5.0 (Windows NT 6.2; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"; break; case IDM_UA_OTHER: default: ASSERT(0); // We should never hit this case return; } setUserAgent(customUserAgent); }
USE_NAMESPACE /* Paramenters: WassupURI: wassup service url -> the caller should retrieve it from customization parameters WassupUsrParam: username parameter name (e.g. wt-email=) -> the caller should retrieve it from customization parameters WassupPwdParam: password parameter name (e.g. wt-pwd=) -> the caller should retrieve it from customization parameters WassupAdditionalParam: additional parameters of the Wassup http request -> the caller should retrieve it from customization parameters config: client config instance needed to retrieve the user agent */ WassupTokenRequestManager::WassupTokenRequestManager(const char* WassupURI, const char* WassupUsrParam, const char* WassupPwdParam, const char* WassupAdditionalParam, const DMTClientConfig& config): _wassupURI(WassupURI), _wassupUsrParam(WassupUsrParam), _wassupPwdParam(WassupPwdParam), _wassupAdditionalParam(WassupAdditionalParam) { setUserAgent(config.getUserAgent()); verifyServerSSL = config.getSSLVerifyServer(); }
int main(int argc, char* argv[]) { unsigned int result = initializeDLLAsRTSPClient(); RTSPClientHandle handle = getNewRTSPHandle(); result = setRTSPURI(handle, "rtsp://192.168.10.222:554/Streaming/Channels/1?transportmode=unicast"); result = setRTSPProtocol(handle, RTSPUsingTCP); result = setUserAgent(handle, "test UserAgent"); result = tryConnectToServer(handle); result = executeOPTIONS(handle); freeRTSPHandle(&handle); result = freeRTSPClinetDLL(); return 0; }
TITANIUM_PROPERTY_SETTER(TiModule, userAgent) { setUserAgent(static_cast<std::string>(argument)); return true; }
void WEnvironment::init(const WebRequest& request) { Configuration& conf = session_->controller()->configuration(); queryString_ = request.queryString(); parameters_ = request.getParameterMap(); urlScheme_ = request.urlScheme(); referer_ = request.headerValue("Referer"); accept_ = request.headerValue("Accept"); serverSignature_ = request.envValue("SERVER_SIGNATURE"); serverSoftware_ = request.envValue("SERVER_SOFTWARE"); serverAdmin_ = request.envValue("SERVER_ADMIN"); pathInfo_ = request.pathInfo(); #ifndef WT_TARGET_JAVA sslInfo_ = request.sslInfo(); #endif setUserAgent(request.headerValue("User-Agent")); LOG_INFO("UserAgent: " << userAgent_); /* * Determine server host name */ if (conf.behindReverseProxy()) { /* * Take the last entry in X-Forwarded-Host, assuming that we are only * behind 1 proxy */ std::string forwardedHost = request.headerValue("X-Forwarded-Host"); if (!forwardedHost.empty()) { std::string::size_type i = forwardedHost.rfind(','); if (i == std::string::npos) host_ = forwardedHost; else host_ = forwardedHost.substr(i+1); } else host_ = request.headerValue("Host"); } else host_ = request.headerValue("Host"); if (host_.empty()) { /* * HTTP 1.0 doesn't require it: guess from config */ host_ = request.serverName(); if (!request.serverPort().empty()) host_ += ":" + request.serverPort(); } clientAddress_ = getClientAddress(request, conf); std::string cookie = request.headerValue("Cookie"); doesCookies_ = !cookie.empty(); if (doesCookies_) parseCookies(cookie, cookies_); locale_ = request.parseLocale(); }
void WEnvironment::updateUrlScheme(const WebRequest& request) { urlScheme_ = str(request.urlScheme()); Configuration& conf = session_->controller()->configuration(); #ifndef WT_TARGET_JAVA if (conf.behindReverseProxy() || server()->dedicatedSessionProcess()) { #else if (conf.behindReverseProxy()){ #endif std::string forwardedProto = str(request.headerValue("X-Forwarded-Proto")); if (!forwardedProto.empty()) { std::string::size_type i = forwardedProto.rfind(','); if (i == std::string::npos) urlScheme_ = forwardedProto; else urlScheme_ = forwardedProto.substr(i+1); } } } void WEnvironment::init(const WebRequest& request) { Configuration& conf = session_->controller()->configuration(); queryString_ = request.queryString(); parameters_ = request.getParameterMap(); host_ = str(request.headerValue("Host")); referer_ = str(request.headerValue("Referer")); accept_ = str(request.headerValue("Accept")); serverSignature_ = str(request.envValue("SERVER_SIGNATURE")); serverSoftware_ = str(request.envValue("SERVER_SOFTWARE")); serverAdmin_ = str(request.envValue("SERVER_ADMIN")); pathInfo_ = request.pathInfo(); #ifndef WT_TARGET_JAVA if(!str(request.headerValue("Redirect-Secret")).empty()) session_->controller()->redirectSecret_ = str(request.headerValue("Redirect-Secret")); sslInfo_ = request.sslInfo(); if(!sslInfo_ && !str(request.headerValue("SSL-Client-Certificates")).empty()) { parseSSLInfo(str(request.headerValue("SSL-Client-Certificates"))); } #endif setUserAgent(str(request.headerValue("User-Agent"))); updateUrlScheme(request); LOG_INFO("UserAgent: " << userAgent_); /* * If behind a reverse proxy, use external host, schema as communicated using 'X-Forwarded' * headers. */ #ifndef WT_TARGET_JAVA if (conf.behindReverseProxy() || server()->dedicatedSessionProcess()) { #else if (conf.behindReverseProxy()){ #endif std::string forwardedHost = str(request.headerValue("X-Forwarded-Host")); if (!forwardedHost.empty()) { std::string::size_type i = forwardedHost.rfind(','); if (i == std::string::npos) host_ = forwardedHost; else host_ = forwardedHost.substr(i+1); } } if (host_.empty()) { /* * HTTP 1.0 doesn't require it: guess from config */ host_ = request.serverName(); if (!request.serverPort().empty()) host_ += ":" + request.serverPort(); } clientAddress_ = getClientAddress(request, conf); const char *cookie = request.headerValue("Cookie"); doesCookies_ = cookie; if (cookie) parseCookies(cookie, cookies_); locale_ = request.parseLocale(); } #ifndef WT_TARGET_JAVA void WEnvironment::parseSSLInfo(const std::string& json) { #ifdef WT_WITH_SSL Wt::Json::Object obj; Wt::Json::ParseError error; if(!Wt::Json::parse(Wt::Utils::base64Decode(json), obj, error)) { LOG_ERROR("error while parsing client certificates"); return; } std::string clientCertificatePem = obj["client-certificate"]; X509* cert = Wt::Ssl::readFromPem(clientCertificatePem); if(cert) { Wt::WSslCertificate clientCert = Wt::Ssl::x509ToWSslCertificate(cert); X509_free(cert); Wt::Json::Array arr = obj["client-pem-certification-chain"]; std::vector<Wt::WSslCertificate> clientCertChain; for(unsigned int i = 0; i < arr.size(); ++i ) { clientCertChain.push_back(Wt::Ssl::x509ToWSslCertificate(Wt::Ssl::readFromPem(arr[i]))); } Wt::WValidator::State state = static_cast<Wt::WValidator::State>((int)obj["client-verification-result-state"]); Wt::WString message = obj["client-verification-result-message"]; sslInfo_ = new Wt::WSslInfo(clientCert, clientCertChain, Wt::WValidator::Result(state, message)); } #endif // WT_WITH_SSL }
NetworkClient::NetworkClient(void) { #ifndef IU_CLI _mutex.acquire(); #endif if(!_curl_init) { enableResponseCodeChecking_ = true; curl_global_init(CURL_GLOBAL_ALL); curl_version_info_data * infoData = curl_version_info(CURLVERSION_NOW); _is_openssl = strstr(infoData->ssl_version, "WinSSL")!=infoData->ssl_version; #ifdef WIN32 GetModuleFileNameA(0, CertFileName, 1023); int i, len = lstrlenA(CertFileName); for(i=len; i>=0; i--) { if(CertFileName[i] == '\\') { CertFileName[i+1] = 0; break; } } strcat(CertFileName, "curl-ca-bundle.crt"); #endif atexit(&curl_cleanup); _curl_init = true; } #ifndef IU_CLI _mutex.release(); #endif m_hOutFile = 0; chunkOffset_ = -1; chunkSize_ = -1; chunk_ = 0; m_CurrentFileSize = -1; m_uploadingFile = NULL; *m_errorBuffer = 0; m_progressCallbackFunc = NULL; curl_handle = curl_easy_init(); // Initializing libcurl m_bodyFuncData.funcType = funcTypeBody; m_bodyFuncData.nmanager = this; m_UploadBufferSize = 65536; m_headerFuncData.funcType = funcTypeHeader; m_headerFuncData.nmanager = this; m_nUploadDataOffset = 0; treatErrorsAsWarnings_ = false; curl_easy_setopt(curl_handle, CURLOPT_COOKIELIST, ""); setUserAgent("Mozilla/5.0"); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, private_static_writer); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &m_bodyFuncData); curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, &m_headerFuncData); curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, m_errorBuffer); curl_easy_setopt(curl_handle, CURLOPT_PROGRESSFUNCTION, &ProgressFunc); curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl_handle, CURLOPT_PROGRESSDATA, this); curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl_handle, CURLOPT_ENCODING, ""); curl_easy_setopt(curl_handle, CURLOPT_SOCKOPTFUNCTION, &set_sockopts); curl_easy_setopt(curl_handle, CURLOPT_SOCKOPTDATA, this); #ifdef _WIN32 curl_easy_setopt(curl_handle, CURLOPT_CAINFO, CertFileName); #endif curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 1L); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 2L); //curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); //curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); //We want the referrer field set automatically when following locations curl_easy_setopt(curl_handle, CURLOPT_AUTOREFERER, 1L); curl_easy_setopt(curl_handle, CURLOPT_BUFFERSIZE, 32768L); curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 0L); }