portsnap is the tool used on FreeBSD to download the ports tree and to update it. Internally, portsnap uses phttpget to download the various files to work with. The problem of the latter is that it does not handle very well the http_proxy variable, that is set when behind an http proxy. Well, let's say, phttpget handles http_proxy very badly: when the http_proxy variable is in the form of
the program does a very awkward parsing of the variable value getting the "password@proxy:port" as the proxy port, that is it gets confused by the colon within the string. This is of course very annoying and prevents the adoption of FreeBSD behind an http proxy. I searched by myself the solution for quite a lot, and finally I wrote a simple patch to portsnap to substitute the use of phttpget with wget, that handles normally the http_proxy variable.
The result is available on one of my git repositories and can be applied as follows (I suggest making a copy of portsnap into portsnap_wget):
cp /usr/bin/portsnap /usr/bin/portsnap_wget
patch -p0 /usr/bin/portsnap_wget portsnap_wget.diff
After that, and assuming of course that you have installed wget from either packages or ports, it is possible to use the portsnap_wget command as the usual portsnap to download updates either when behind a proxy or not:
portsnap_wget fetch update
With regard to the patch, it did not involved only changing the download program to wget, but also to change the definition of the files to download, that now are not passed via xargs but within a loop.