Mis authentication to Arduino server

Hello, while trying to understand Ethernet connection reliability issue from my router to Arduino server, I use a wget in the following loop

set CUR_HH=%time:~0,2%
if %CUR_HH% lss 10 (set CUR_HH=0%time:~1,1%)
set CUR_NN=%time:~3,2%
set CUR_SS=%time:~6,2%
set temps=%CUR_HH%%CUR_NN%%CUR_SS%
@echo time: %date% %time% >> out.txt
wget --user=abc --password=def --append-output=wgetout.txt --output-document=new.html
type new.html >> all.html
timeout %INTERVAL%

What I am seeing is that wget not always does authentifies: ~ half of the accesses it omits "Authorization: Basic <base 64 user / password>"

Can someone tell what am I missing? Thanks

Hard to tell without seeing the complete output. My guess is it does send the credentials only if the corresponding server asked for it before.

No, the server does not ask for the credentials.
if it does not receive Authorization: Basic followed by correct credentials
It simply calls serveAuthPage() and closes the cnx

void serveAuthPage() {
  report(F("server-> sending auth page\r\n"), MI_VERB);
  client.println(F("HTTP/1.1 401 Authorization Required"));
  client.println(F("WWW-Authenticate: Basic realm=\"Secure Area\""));
  client.println(F("Content-Type: text/html"));
  client.println(F("Connnection: close"));
  client.println(F("<!DOCTYPE HTML>"));
  client.println(F("<HTML>  <HEAD>   <TITLE>Error</TITLE>"));
  client.println(F(" </HEAD> <BODY><H1>401 Unauthorized.</H1></BODY> </HTML>"));

BTW, now that I understood the behavior, I suppressed the authentification for the tests and am running the test overnight. The issue I am about to solve is here

That's exactly what I meant by asking for the credentials. It returns a 401 error with the corresponding WWW-Athenticate header.

Sorry, you're right. Obviously the server cannot tell the client it expects authentication before the client accesses the server ::slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.