I'm using bzr 1.13.1 on Jaunty.
Here is what I get with debug enabled (let me know if you still need ~/.bzr.log or any other info):
-----------------------------------------------------------
blfgomes@ubuntu-desktop:~/packaging/bzr$ bzr branch http://bazaar.launchpad.net/~blfgomes/+junk/myproject
Will unbind ftp_open for 'ftp://blfgomes:passwd@proxy:8080/'
Will unbind http_open for 'http://blfgomes:passwd@proxy:8080/'
Will unbind https_open for 'https://blfgomes:passwd@proxy:8080/'
Will bind http_request for 'http://blfgomes:passwd@proxy:8080/'
Will bind http_request for 'https://blfgomes:passwd@proxy:8080/'
{'addheaders': [('User-agent', 'Python-urllib/2.6')],
'handle_error': {'accepted': {'errors': [<bzrlib.transport.http._urllib2_wrappers.HTTPErrorProcessor instance at 0x91ca26c>]},
'http': {301: [<bzrlib.transport.http._urllib2_wrappers.HTTPRedirectHandler instance at 0x91ca22c>],
302: [<bzrlib.transport.http._urllib2_wrappers.HTTPRedirectHandler instance at 0x91ca22c>],
303: [<bzrlib.transport.http._urllib2_wrappers.HTTPRedirectHandler instance at 0x91ca22c>],
307: [<bzrlib.transport.http._urllib2_wrappers.HTTPRedirectHandler instance at 0x91ca22c>],
401: [<bzrlib.transport.http._urllib2_wrappers.HTTPNegotiateAuthHandler instance at 0x91cbf4c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPDigestAuthHandler instance at 0x91cbf2c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPBasicAuthHandler instance at 0x91cbeac>],
407: [<bzrlib.transport.http._urllib2_wrappers.ProxyNegotiateAuthHandler instance at 0x91cbfac>,
<bzrlib.transport.http._urllib2_wrappers.ProxyDigestAuthHandler instance at 0x91cbf8c>,
<bzrlib.transport.http._urllib2_wrappers.ProxyBasicAuthHandler instance at 0x91cbf6c>],
'default': [<bzrlib.transport.http._urllib2_wrappers.HTTPDefaultErrorHandler instance at 0x91ca30c>]}},
'handle_open': {'file': [<urllib2.FileHandler instance at 0x91ca18c>],
'ftp': [<urllib2.FTPHandler instance at 0x91ca0cc>],
'http': [<bzrlib.transport.http._urllib2_wrappers.HTTPHandler instance at 0x91ca20c>,
<urllib2.HTTPHandler instance at 0x91ca08c>],
'https': [<bzrlib.transport.http._urllib2_wrappers.HTTPSHandler instance at 0x91ca2ec>,
<urllib2.HTTPSHandler instance at 0x91ca12c>],
'unknown': [<urllib2.UnknownHandler instance at 0x91ca02c>]},
'handlers': [<bzrlib.transport.http._urllib2_wrappers.ProxyHandler instance at 0x91cbe8c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPHandler instance at 0x91ca20c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPSHandler instance at 0x91ca2ec>,
<bzrlib.transport.http._urllib2_wrappers.HTTPNegotiateAuthHandler instance at 0x91cbf4c>,
<bzrlib.transport.http._urllib2_wrappers.ProxyNegotiateAuthHandler instance at 0x91cbfac>,
<bzrlib.transport.http._urllib2_wrappers.HTTPDigestAuthHandler instance at 0x91cbf2c>,
<bzrlib.transport.http._urllib2_wrappers.ProxyDigestAuthHandler instance at 0x91cbf8c>,
<urllib2.UnknownHandler instance at 0x91ca02c>,
<urllib2.HTTPHandler instance at 0x91ca08c>,
<urllib2.FTPHandler instance at 0x91ca0cc>,
<urllib2.FileHandler instance at 0x91ca18c>,
<urllib2.HTTPSHandler instance at 0x91ca12c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPRedirectHandler instance at 0x91ca22c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPBasicAuthHandler instance at 0x91cbeac>,
<bzrlib.transport.http._urllib2_wrappers.ProxyBasicAuthHandler instance at 0x91cbf6c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPDefaultErrorHandler instance at 0x91ca30c>,
<bzrlib.transport.http._urllib2_wrappers.ConnectionHandler instance at 0x91cbe6c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPErrorProcessor instance at 0x91ca26c>],
'process_request': {'http': [<bzrlib.transport.http._urllib2_wrappers.ProxyHandler instance at 0x91cbe8c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPHandler instance at 0x91ca20c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPSHandler instance at 0x91ca2ec>,
<bzrlib.transport.http._urllib2_wrappers.HTTPNegotiateAuthHandler instance at 0x91cbf4c>,
<bzrlib.transport.http._urllib2_wrappers.ProxyNegotiateAuthHandler instance at 0x91cbfac>,
<bzrlib.transport.http._urllib2_wrappers.HTTPDigestAuthHandler instance at 0x91cbf2c>,
<bzrlib.transport.http._urllib2_wrappers.ProxyDigestAuthHandler instance at 0x91cbf8c>,
<urllib2.HTTPHandler instance at 0x91ca08c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPBasicAuthHandler instance at 0x91cbeac>,
<bzrlib.transport.http._urllib2_wrappers.ProxyBasicAuthHandler instance at 0x91cbf6c>,
<bzrlib.transport.http._urllib2_wrappers.ConnectionHandler instance at 0x91cbe6c>],
'https': [<bzrlib.transport.http._urllib2_wrappers.ProxyHandler instance at 0x91cbe8c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPSHandler instance at 0x91ca2ec>,
<bzrlib.transport.http._urllib2_wrappers.HTTPNegotiateAuthHandler instance at 0x91cbf4c>,
<bzrlib.transport.http._urllib2_wrappers.ProxyNegotiateAuthHandler instance at 0x91cbfac>,
<bzrlib.transport.http._urllib2_wrappers.HTTPDigestAuthHandler instance at 0x91cbf2c>,
<bzrlib.transport.http._urllib2_wrappers.ProxyDigestAuthHandler instance at 0x91cbf8c>,
<urllib2.HTTPSHandler instance at 0x91ca12c>,
<bzrlib.transport.http._urllib2_wrappers.HTTPBasicAuthHandler instance at 0x91cbeac>,
<bzrlib.transport.http._urllib2_wrappers.ProxyBasicAuthHandler instance at 0x91cbf6c>,
<bzrlib.transport.http._urllib2_wrappers.ConnectionHandler instance at 0x91cbe6c>]},
'process_response': {'http': [<bzrlib.transport.http._urllib2_wrappers.HTTPErrorProcessor instance at 0x91ca26c>],
'https': [<bzrlib.transport.http._urllib2_wrappers.HTTPErrorProcessor instance at 0x91ca26c>]}}
set_proxy http_request for 'http://blfgomes:passwd@proxy:8080/'
set_proxy: proxy set to http://proxy:8080
send: 'POST http://bazaar.launchpad.net/%7Eblfgomes/%2Bjunk/myproject/.bzr/smart HTTP/1.1\r\nAccept-Encoding: identity\r\nContent-Length: 6\r\nConnection: Keep-Alive\r\nAccept: */*\r\nUser-Agent: bzr/1.13.1 (urllib)\r\nHost: bazaar.launchpad.net\r\nPragma: no-cache\r\nCache-Control: max-age=0\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n'
send: 'hello\n' 0kB/s
Request sent: [<bzrlib.transport.http._urllib2_wrappers.Request instance at 0x91cedcc>] from (('192.168.126.128', 35743))
reply: 'HTTP/1.1 407 Proxy Authentication Required\r\n'
header: Content-Length: 2445
header: Proxy-Authenticate: NTLM
header: Proxy-Authenticate: Basic realm="Webwasher"
header: Proxy-Connection: close
Receives response: <bzrlib.transport.http._urllib2_wrappers.Response instance at 0x91eb1cc>
For: 'POST'('http://bazaar.launchpad.net/%7Eblfgomes/%2Bjunk/myproject/.bzr/smart')
Create addinfourl: <addinfourl at 153006988 whose fp = <socket._fileobject object at 0x91e8a3c>>
For: 'POST'('http://bazaar.launchpad.net/%7Eblfgomes/%2Bjunk/myproject/.bzr/smart')
set_proxy http_request for 'http://blfgomes:passwd@proxy:8080/'
set_proxy: proxy set to http://proxy:8080
send: 'GET http://bazaar.launchpad.net/%7Eblfgomes/%2Bjunk/myproject/.bzr/branch-format HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: bazaar.launchpad.net\r\nAccept: */*\r\nUser-Agent: bzr/1.13.1 (urllib)\r\nConnection: Keep-Alive\r\nPragma: no-cache\r\nCache-Control: max-age=0\r\n\r\n'
Request sent: [<bzrlib.transport.http._urllib2_wrappers.Request instance at 0x91cae8c>] from (('192.168.126.128', 35744))
reply: 'HTTP/1.1 407 Proxy Authentication Required\r\n'
header: Content-Length: 2461
header: Proxy-Authenticate: NTLM
header: Proxy-Authenticate: Basic realm="Webwasher"
header: Proxy-Connection: close
Receives response: <bzrlib.transport.http._urllib2_wrappers.Response instance at 0x91eb38c>
For: 'GET'('http://bazaar.launchpad.net/%7Eblfgomes/%2Bjunk/myproject/.bzr/branch-format')
Create addinfourl: <addinfourl at 153007180 whose fp = <socket._fileobject object at 0x91e8cdc>>
For: 'GET'('http://bazaar.launchpad.net/%7Eblfgomes/%2Bjunk/myproject/.bzr/branch-format')
bzr: ERROR: Invalid http response for http://bazaar.launchpad.net/%7Eblfgomes/%2Bjunk/myproject/.bzr/branch-format: Unable to handle http code 407: Proxy Authentication Required
------------------------------------------------------------------------
Note: I'm aware bzr doesn't support NTLM authentication, but since I'm passing the credentials through the HTTP_PROXY variable, it should work. Also note that wget and urllib2.urlopen are able to authenticate when HTTP_PROXY is set.
There's some description of NTLM proxy auth here: http:// squid.sourcefor ge.net/ ntlm/client_ proxy_protocol. html
I may be missing your point but if the proxy requires NTLM it's not going to be enough for bzr to just have the username/password in the HTTP_PROXY setting. bzr (or the library it uses) needs to know how to do the fairly complicated dance to open the connection.
However, if urllib2 can do this in other cases, but bzr's use of urllib2 doesn't work we may be able to fix it.
Can you give an example of some urllib2 code that does work in this case?
As a workaround you may be able to use ssh to Launchpad.