cabal-install sends invalid proxy password

Valery V. Vorotyntsev valery.vv at
Fri Dec 12 09:05:45 EST 2008

Dear lazy programmers,

I was surprised to discover that `cabal-install' -- a popular utility
for installing Hackage packages -- cannot work with HTTP proxies.
Despite all the necessary code linked in.

`cabal update' command returns HTTP 407 (Proxy Authentication Required)
error.  The problem is explained below and patches follow.

                                * * *

Our office LAN has an HTTP proxy server with authorization.
And my shell environment has a variable like


tcpdump-ing shows that `cabal update' sends invalid credentials in
HTTP "CONNECT" request. The proper string would be "user:password"
(base64-encoded) while `cabal' sends "user:password@".  There's no
surprise proxy server denies connection!

I've traced the problem down to `userinfo' function, defined in

> --  RFC3986, section 3.2.1
> userinfo :: URIParser String
> userinfo =
>     do  { uu <- many (uchar ";:&=+$,")
>         ; char '@'
>         ; return (concat uu ++"@")
>         }

Let us see section 3.2 of RFC3986:

>    authority   = [ userinfo "@" ] host [ ":" port ]
> [...
>           ...] The user information, if present, is followed by a
> commercial at-sign ("@") that delimits it from the host.

There is no reason for "@" character to be a part of `userinfo'

                                * * *

So, the Right Way(TM) to make cabal-install go through proxies is
fixing `userinfo' function of `network' package (see the
`network-'). Until then, we should have a workaround in
`cabal-install' (cabal-install-0.6.0.patch). I do.

Happy hacking!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: network-
Type: application/octet-stream
Size: 1598 bytes
Desc: not available
Url :
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cabal-install-0.6.0.patch
Type: application/octet-stream
Size: 799 bytes
Desc: not available
Url :

More information about the cabal-devel mailing list