client.print("HTTP/1.1 401 Authorization Required\r\n");
client.print("WWW-Authenticate: Digest realm=\"quello che ti pare\", nonce=\"******\", algorithm=\"MD5\", qop=\"auth-int\", opaque=\"******\"\r\n");
client.println("Content-Type: text/html");
ti apparirà la finestra di login usarname e passw in entrambi i casi, arduino deve solo confrontare delle stringhe codificate che invia il client che possono essere a 16 char nel caso Basic e a 32 char nel caso Digest, fine dei giochi
cerca bene che qualcosa trovi , ricorda una cosa importante, quando qui su questo forum ti risponde qualcuno/a difficilmentre troverai quello che ti risponde facendo supposizioni tanto per buttare via 5 minuti, al massimo ti viene scritto "prova ma non sono sicuro" o non ti rispondono proprio
ciao buon lavoro
Dunque ora che hai messo user=antonino e pass=ciao nel popup di autenticazione ti renderai conto che il base64 non è poi una decodifica così sicura ma che comunque e meglio di niente.
Hai postato troppo poco per capire cosa stai facendo, ti conviene utilizzare una libreria già fatta che fa un analisi dettagliata della risposta http in tutte le sue parti e nel caso modificarla, io non ho arduino al momento disponibile per rifare dei test su lavori già fatti mesi fa, non ti sei buttato in una cosa semplicissima ci vuole molta pazienza e tempo ma riuscirai a ottenere dei buoni risultati.
prova a pubblicare quello cha hai fatto fino ad ora nell'insieme, qualcuno lo caricherà e magari può esserti di aiuto.
Parto dal più semplice. Più avanti potrei svilupparlo meglio.
Ti giro l'originale, tramite client.read estraggo i dati inviati dal client e li salvo su HTTP_req
qui mi fermo....
EthernetClient client = server.available(); // try to get client
if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
// limit the size of the stored received HTTP request
// buffer first part of HTTP request in HTTP_req array (string)
// leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
if (req_index < (REQ_BUF_SZ - 1)) {
HTTP_req[req_index] = c; // save HTTP request character
req_index++;
}
// last line of client request is blank and ends with \n
// respond to client only after last line received
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
// remainder of header follows below, depending on if
// web page or XML page is requested
// Ajax request - send XML file
if (StrContains(HTTP_req, "ajax_inputs")) {
// send rest of HTTP header
client.println("Content-Type: text/xml");
client.println("Connection: keep-alive");
client.println();
SetLEDs();
// send XML file containing input states
XML_response(client);
}
else { // web page request
// send rest of HTTP header
client.println("Content-Type: text/html");
client.println("Connection: keep-alive");
client.println();
// send web page
webFile = SD.open("index.htm"); // open web page file
if (webFile) {
while(webFile.available()) {
client.write(webFile.read()); // send web page to client
}
webFile.close();
}
}
// display received HTTP request on serial port
Serial.print(HTTP_req);
// reset buffer index and all buffer elements to 0
req_index = 0;
StrClear(HTTP_req, REQ_BUF_SZ);
break;
}
// every line of text received from the client ends with \r\n
if (c == '\n') {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
}
else if (c != '\r') {
// a text character was received from client
currentLineIsBlank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)
}