Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.4k views
in FAQ: CompleteFTP by (161k points)
closed by
How can I use wget to download using authenticated HTTP?
closed with the note: Answered

1 Answer

0 votes
by (20.4k points)
 
Best answer

To download from CompleteFTP using wget requires two steps (for files that require username/password).

CompleteFTP uses a session id, stored as a cookie. Clients must first obtain the cookie, and then authenticate using that cookie. By default, wget sends the authorization header in the first request (before the cookie is sent). This never works, as the cookie is not sent to the server with the auth header. CompleteFTP assumes this is an expired session.

So wget must be run twice, first to get the cookie, and then again using the retrieved cookie:

wget --save-cookies cookies.txt --keep-session-cookies http://myurl
wget --load-cookies cookies.txt --http-user=username --http-password=pwd http://myurl


This only works in wget version 1.12 or later since earlier versions don't save the cookie if there's an authentication error.

...