19 virtual int readlnInternal(
Stream& client, uint8_t* str,
int len,
20 bool incl_nl =
true) {
22 LOGD(
"HttpLineReader %s",
"readlnInternal");
24 for (
int w = 0; w < 200 && client.available() == 0; w++) {
28 if (client.available() == 0) {
29 LOGW(
"HttpLineReader %s",
"readlnInternal->no Data");
35 bool is_buffer_overflow =
false;
38 int c = client.read();
46 is_buffer_overflow =
true;
56 if (str[j - 1] ==
'\r') {
68 if (!is_buffer_overflow) {
74 if (is_buffer_overflow) {
88 int non_printable = 0;
92 for (
int i = 0; i < len && str[i] != 0; i++) {
94 if (str[i] >= 32 && str[i] <= 126) {
96 }
else if (str[i] !=
'\r' && str[i] !=
'\n' && str[i] !=
'\t') {
105 int log_len = (actual_len > 256) ? 256 : actual_len;
108 if (non_printable > printable) {
109 LOGE(
"Line cut off: [%d bytes, %d binary chars - showing hex dump of first %d bytes]",
110 actual_len, non_printable, (log_len > 32 ? 32 : log_len));
114 int hex_len = (log_len > 32) ? 32 : log_len;
115 for (
int i = 0; i < hex_len; i += 16) {
117 int line_len = (hex_len - i > 16) ? 16 : (hex_len - i);
119 for (
int j = 0; j < line_len; j++) {
120 pos += snprintf(hex_line + pos,
sizeof(hex_line) - pos,
"%02X ", (uint8_t)str[i + j]);
122 LOGE(
" %04X: %s", i, hex_line);
127 if (log_len < actual_len) {
128 char saved = str[log_len];
130 LOGE(
"Line cut off: %s... [%d more bytes]", str, actual_len - log_len);
131 str[log_len] = saved;
133 LOGE(
"Line cut off: %s", str);