I was looking at a simple web_server code that fetches an index.txt and reads the values inside the text. I was curious about the purpose of client.print and the following lines of code. Could someone provide me with an explanation (explain like I am 5)
// This will send the request to the server client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); delay(500);
Why do I need:
"Host: " + host + "\r\n" +
It seems not to work without that, but some examples that I have read online emit those lines . This is an example from the client.available reference.
client.println("GET /search?q=arduino HTTP/1.0");