God - this bugged me no end at my workplace. Especially the interplay of sudo, loading environment variables, etc. with http proxy.
Rule of thumb is - sudo (if present) should be the first command, http_proxy (if present) should be the second and then the rest of the actual command
Effectively, it is something like
sudo http_proxy=http://126.96.36.199:80 apt-get update