libfetch: Fix PROXY_HOST bug, socket leak, cache-crash
As described in FreeBSD PR kern/139751, NO_PROXY=localhost doesn't work
due to bad for loop count.
As described in FreeBSD PR kern/153748, an ftp-cached connection will
close the connection too early when trying to send a request.
There is a socket leak in ftp_request that occurs after a connection is
established. Make sure socket is disconnected before exiting.
Taken-From: FreeBSD SVN 198339 (21 OCT 2009)
Taken-From: FreeBSD SVN 199801 (25 NOV 2009)
Taken-From: FreeBSD SVN 217505 (17 JAN 2011)