Skip to content

Commit c6fb71a

Browse files
available() shouldn't return 0 if there is still data to read. fixed logic to include correctly include peeked byte in available count
1 parent a9779a8 commit c6fb71a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

libraries/WiFiClientSecure/src/WiFiClientSecure.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,15 @@ int WiFiClientSecure::read(uint8_t *buf, size_t size)
209209

210210
int WiFiClientSecure::available()
211211
{
212-
if (!_connected) {
213-
return 0;
212+
int res = 0;
213+
if (_connected) {
214+
res = data_to_read(sslclient);
215+
if (res < 0 ) {
216+
stop();
217+
res = 0;
218+
}
214219
}
215-
int res = data_to_read(sslclient);
216-
if (res < 0 ) {
217-
stop();
218-
} else if(_peek >= 0) {
220+
if(_peek >= 0) {
219221
res += 1;
220222
}
221223
return res;

0 commit comments

Comments
 (0)