diff --git a/src/osgPlugins/curl/CMakeLists.txt b/src/osgPlugins/curl/CMakeLists.txt index ff705897a..55c0eb74b 100644 --- a/src/osgPlugins/curl/CMakeLists.txt +++ b/src/osgPlugins/curl/CMakeLists.txt @@ -1,5 +1,7 @@ #this file is automatically generated +INCLUDE_DIRECTORIES( ${CURL_INCLUDE_DIRS} ) + SET(TARGET_SRC ReaderWriterCURL.cpp ) SET(TARGET_EXTERNAL_LIBRARIES ${CURL_LIBRARY} ) diff --git a/src/osgPlugins/curl/ReaderWriterCURL.cpp b/src/osgPlugins/curl/ReaderWriterCURL.cpp index 60f2205fe..7863a003f 100644 --- a/src/osgPlugins/curl/ReaderWriterCURL.cpp +++ b/src/osgPlugins/curl/ReaderWriterCURL.cpp @@ -111,6 +111,32 @@ class ReaderWriterCURL : public osgDB::ReaderWriter virtual ReadResult readFile(ObjectType objectType, const std::string& fullFileName, const Options *options) const { + std::string cacheFilePath, cacheFileName; + std::string proxyAddress, optProxy, optProxyPort; + + if (options) + { + std::istringstream iss(options->getOptionString()); + std::string opt; + while (iss >> opt) + { + int index = opt.find( "=" ); + if( opt.substr( 0, index ) == "OSG_FILE_CACHE" ) + cacheFilePath = opt.substr( index+1 ); //Setting Cache Directory by OSG Options + else if( opt.substr( 0, index ) == "OSG_CURL_PROXY" ) + optProxy = opt.substr( index+1 ); + else if( opt.substr( 0, index ) == "OSG_CURL_PROXYPORT" ) + optProxyPort = opt.substr( index+1 ); + } + + //Setting Proxy by OSG Options + if(!optProxy.empty()) + if(!optProxyPort.empty()) + proxyAddress = optProxy + ":" + optProxyPort; + else + proxyAddress = optProxy + ":8080"; //Port not found, using default + } + if (!osgDB::containsServerAddress(fullFileName)) { if (options && !(options->getDatabasePathList().empty())) @@ -145,23 +171,42 @@ class ReaderWriterCURL : public osgDB::ReaderWriter osg::notify(osg::NOTICE)<<"Error: No ReaderWriter for file "<readObject(cacheFileName,options); } + const char* proxyEnvAddress = getenv("OSG_CURL_PROXY"); + if (proxyEnvAddress) //Env Proxy Settings + { + const char* proxyEnvPort = getenv("OSG_CURL_PROXYPORT"); //Searching Proxy Port on Env + + if(proxyEnvPort) + proxyAddress = std::string(proxyEnvAddress) + ":" + std::string(proxyEnvPort); + else + proxyAddress = std::string(proxyEnvAddress) + ":8080"; //Default + } + + if(!proxyAddress.empty()) + { + osg::notify(osg::NOTICE)<<"Setting proxy: "<getDatabasePathList().pop_front(); - if (fileCachePath && readResult.validObject()) + if (!cacheFilePath.empty() && readResult.validObject()) { osg::notify(osg::NOTICE)<<"Writing cache file "<