FAQ for CompleteFTP
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

How can I use wget to download using authenticated HTTP?

by support2 » Tue Jul 26, 2011 2:16 pm

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.

Who is online

Users browsing this forum: No registered users and 20 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign