Disabling 'http_proxy' not working as expected

John Arbash Meinel john at arbash-meinel.com
Fri May 16 17:21:24 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ben Finney wrote:
| Vincent Ladeuil <v.ladeuil+lp at free.fr> writes:
|
|>>>>>> "Ben" == Ben Finney <bignose+hates-spam at benfinney.id.au> writes:
|>     Ben> Ben Finney <bignose+hates-spam at benfinney.id.au> writes:
|>     >> In a later message in this thread, I demonstrated the same problem
|>     >> occuring with an empty 'http_proxy' veriable.
|>     Ben> Except apparently I didn't.
|
| Wow, that's one really annoying quoting style. Could you please use
| normal attribution lines and '> ' quote leaders?
|
|> Looks like echo has the same problem... or not ?
|
| 'echo' is usually implemented as a shell built-in, operating entirely
| within the current shell's environment, so is perhaps not a good
| comparison to make with an external program like 'bzr'.
|

I don't see any reason why we wouldn't be getting the correct environment variable.

$ export myvar=bar
$ myvar=foo python -c "import os; print os.environ['myvar']"
foo

you can even do something like this:

echo -e "import os\nprint 'http_proxy=', os.environ.get('http_proxy')" > \
~  ~/.bazaar/plugins/http_proxy.py

On my system I get:
$ bzr st
http_proxy= None
$ http_proxy=foo bzr st
http_proxy= foo

which seems perfectly valid, and seems to contradict your findings.

Now, we are using python's urllib.getproxies function to determine what proxies
are active, and it uses this code:

proxies = {}
for name, value in os.environ.items():
~    name = name.lower()
~    if value and name[-6:] == '_proxy':
~        proxies[name[:-6]] = value
return proxies


Which seems like it searches the whole env vars for anything ending with
'proxy'. So it should find "http_proxy", "HTTP_PROXY", "foo_proxy", and an
important one "all_proxy".

Because later on we have:

~    def get_proxy_env_var(self, name, default_to='all'):
	...
~        try:
~            return self.proxies[name.lower()]
~        except KeyError:
~            if default_to is not None:
~                # Try to get the alternate environment variable
~                try:
~                    return self.proxies[default_to]
~                except KeyError:
~                    pass
~        return None


So if "http_proxy" is set, *or* "all_proxy" is set, then it should use it.


I've tried lots of combinations, and everything I've tried shows that doing:

$ http_proxy= bzr st
http_proxy= None

Which seems what you want. So my best guess is that you have another env
variable. Like maybe "HTTP_PROXY", or "ALL_PROXY", etc. Though why doing
unset http_proxy
export http_proxy

fixes it for you is beyond me.

You might try the plugin trick to see what env var bzr is getting. It is, after
all, just another program, without any magic ability to probe into the real
shell settings.

Do you have 'bzr' aliased/symlinked/etc to something else?

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgttIQACgkQJdeBCYSNAAO3VQCgk6M7blf5+myHAHjEC8DdmQeT
o3MAn0AmA6r9KtbzgQZD3foqdwEwASmX
=QfWM
-----END PGP SIGNATURE-----



More information about the bazaar mailing list