Why does WGET return 2 error messages before they are completed?

I am using a script to pull some XML data to the URL required for authentication using WGET.

In doing so, my script generates the following output for each URL (IP addresses and hostnames changed to protect those responsible):

> Resolving host.name.com... 127.0.0.1 > Connecting to host.name.com|127.0.0.1|:80... connected. > HTTP request sent, awaiting response... 401 Access denied > Connecting to host.name.com|127.0.0.1|:80... connected. > HTTP request sent, awaiting response... 401 Unauthorized > Reusing existing connection to host.name.com:80. > HTTP request sent, awaiting response... 200 OK 

Why does WGET complain that access to the URL failed twice before successfully connecting? Is there a way to close it or make it connect correctly on the first try?

For reference, here is the line I use to call WGET:

 wget --http-user=USERNAME --password=PASSWORD -O file.xml http://host.name.com/file.xml 
+4
source share
2 answers

It looks like a design. Following @Wayne Conrad's advice, I added the -d switch and was able to observe the first attempt at failure, because NTLM is required, and the second attempt failed, because the first NTLM attempt was only level 1, where NTLM level 3 call - the answer was needed. WGET finally provides the necessary authentication on the third try.

WGET receives a cookie to prevent re-authentication throughout the session, which will prevent this if the connection is not completed between files. I will need to give WGET a list of files for this, but I cannot, because I do not know the file names in advance.

+4
source

You seem to have a new version of wget. After 1.10.2, wget will not send authentication unless the server requests the server. And that is why the first of them fails. The second reason is not what you described.

You can reduce one of them by adding the --auth-no-challenge option. This sends the first in the β€œbase” which will not be executed, and the second will be sent in the β€œdigest” mode. What should work.

+2
source

All Articles