At the start of the response, there are 407 available
bytes, and the Content-Length
of the body is 255
. The buffer is only
char buf[200]; // buffer big enough for expected response
So making that at least 408 (don't forget the trailing null) will read the rest. The stack might be getting tight though; so better yet, to print the whole response regardless of size and return the status code, use instead
int statusFromResponse(WiFiClient &client) {
size_t p = 0;
size_t available = 0;
// wait for first byte
while (client.connected()) {
if (available = client.available()) {
break;
}
delay(1);
p++;
}
if (!available) {
Serial.println("not connected");
return 0;
}
Serial.printf("waited %d for %d available --->\n", p, available);
int code = -1;
size_t t = 0;
char buf[200];
while (client.connected() && available) {
p = client.read((uint8_t *)buf, std::min(available, sizeof(buf) - 1));
if (t == 0) {
sscanf(buf, "HTTP/%*s %d", &code);
}
t += p;
buf[p] = 0;
Serial.print(buf);
available = client.available();
}
Serial.printf("<---\n%d total\n", t);
return code;
}
and so the two function calls are replaced with a single one, with no buffer
Serial.printf("status: %d\n", statusFromResponse(wifi));
If we're lucky, the remaining 200-ish bytes will have useful details.