Ok now I feel silly. I just fixed it using the tip by @oqibidipo earlier.
All I had to do was add \r\n before the HTML payload in the authentication function
void SendAuthentificationpage(EthernetClient &client)
{
client.print(F(
"HTTP/1.1 401 Authorization Required\r\n"
"WWW-Authenticate: Basic realm=\"Secure Area\"\r\n"
"Content-Type: text/html\r\n"
"Connnection: close\r\n"
"\r\n"
"<!DOCTYPE HTML>"
"<HTML> <HEAD> <TITLE>Error</TITLE>"
" </HEAD> <BODY><H1>401 Unauthorized.</H1></BODY> </HTML>"
));
}
Going back to my second question if someone can assist, how would I display a variable using client.print(f(); . You can see in the above post I tried to display temperature but I'm sure there's a better way.