Open glennpierce opened 3 years ago
@glennpierce did you ever determine how to do this? running into a similar problem
No sorry I didn't as my work moved on to another solution. Just as well really because of the lack of reply.
The main issue is that calling responseBody
eats up all the header information from the response. This might be considered a bug, or an undocumented feature.
A workaround is that you need to read the response headers first as shown in the example below, and then read the body.
int statusCode = httpclient.responseStatusCode();
// read status code
Serial.print("Status code: ");
Serial.println(statusCode);
// read headers
while (httpclient.headerAvailable()) {
Serial.print(httpclient.readHeaderName());
Serial.print(": ");
Serial.println(httpclient.readHeaderValue());
}
// read response
String response = httpclient.responseBody();
Serial.print("Response: ");
Serial.println(response);
Sorry if I have missed this but is there a way to read response headers. I need to access these to do some scram authentication.
I see methods like readHeaderValue and readHeader() but can't work out how it it used.
Thanks