if (client.connected() && client.available()) { // read a row
buffer[0] = client.read();
buffer[1] = client.read();
bufindex = 2;
// read the first line to determinate the request page
while (buffer[bufindex-2] != '\r' && buffer[bufindex-1] != '\n') { // read full row and save it in buffer
c = client.read();
if (bufindex<STRING_BUFFER_SIZE) buffer[bufindex] = c;
bufindex++;
}
If there is at least one character from the server in the buffer, read all three. Don't print c and don't print buffer, and don't NULL terminate buffer. OK, I'll bite. Why?