X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Foptions.cxx;h=b4a3bc830f01596d1678689f0b6c07bc48456a3e;hb=38226af24ec01e8f0a20d7fd73ef838a69f6ef25;hp=78471c8f015e52d719c88e2e9fb1dfa610f5f10c;hpb=9c98258ab08b48420c86cf09c0f6ba9d1ff82700;p=flightgear.git diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 78471c8f0..b4a3bc830 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -98,6 +99,8 @@ atoi( const string& str ) return ::atoi( str.c_str() ); } +static int fgSetupProxy( const char *arg ); + /** * Set a few fail-safe default property values. * @@ -245,6 +248,8 @@ fgSetDefaults () fgSetString("/sim/version/revision", REVISION); fgSetInt("/sim/version/build-number", HUDSON_BUILD_NUMBER); fgSetString("/sim/version/build-id", HUDSON_BUILD_ID); + if( (envp = ::getenv( "http_proxy" )) != NULL ) + fgSetupProxy( envp ); } static bool @@ -896,10 +901,16 @@ fgOptStartDateGmt( const char *arg ) static int fgSetupProxy( const char *arg ) { - string options = arg; + string options = simgear::strutils::strip( arg ); string host, port, auth; string::size_type pos; + // this is NURLP - NURLP is not an url parser + if( simgear::strutils::starts_with( options, "http://" ) ) + options = options.substr( 7 ); + if( simgear::strutils::ends_with( options, "/" ) ) + options = options.substr( 0, options.length() - 1 ); + host = port = auth = ""; if ((pos = options.find("@")) != string::npos) auth = options.substr(0, pos++);