Extra bytes in the response body from the server
Posted: Thu Mar 09, 2023 9:28 am
Esp32 controller. I want to receive and process binary data from the server. The server sends 10 bytes, but the available() method returns 20.
Here's a screenshot of the response, including headers and all characters. As you can see, there are 10 zero bytes in the body. Arduino code for receiving and processing a stream after a successful server response:
This is what is displayed in the console. 20 bytes are available. I have highlighted the actual 10 bytes of data in green. The blue bytes are CL LF. It is not clear what 61 and 30 could mean.
Does anyone have any information on what this might be related to?
Here's a screenshot of the response, including headers and all characters. As you can see, there are 10 zero bytes in the body. Arduino code for receiving and processing a stream after a successful server response:
Code: Select all
if(_httpResponseCode == 200) {
WiFiClient *stream = http.getStreamPtr();
int available = stream->available();
Serial.print("Available ");
Serial.println(available);
//Allocating memory for the response buffer
uint8_t* _result_bufer = new uint8_t[available];
//Reading all bytes from the stream and writing to the buffer
stream->readBytes(_result_bufer, available);
//Printing all received bytes to the console
for(int bytesRead = 0; bytesRead < available ; bytesRead++){
Serial.printf("%02X ", _result_bufer[bytesRead]);
}
_result = _result_bufer;
Serial.println();
Serial.print("Total bytes reads: ");
Serial.println(bytesRead);
}