From 3ccfdac8fe65b1a933148b01d59fad8b764d989a Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Sun, 20 Feb 2011 11:42:21 +0100 Subject: [PATCH 1/2] use http_proxy environment variable --- src/Main/options.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 78471c8f0..bce7fdeb9 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -98,6 +98,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 +247,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 From 6c3035af60abf72fcd61453d5e4edd676fa074b3 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Sun, 20 Feb 2011 17:14:30 +0100 Subject: [PATCH 2/2] allow proxy to set as an url --- src/Main/options.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index bce7fdeb9..b4a3bc830 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -900,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++);