Skip to content

streaming writes to ESP8266HTTPClient over SSL #1274

Closed
@gtalusan

Description

@gtalusan

I have a plain old HTTP response stream (WiFiClient *) that I'm passing to HTTPClient::sendRequest(method, Stream *, size_t) over SSL.

The while-loop in ESP8266HTTPClient.cpp for reading from the stream and writing to the _tcp instance only does one iteration.

    while(connected() && stream->available() && (len > 0 || len == -1)) {

shouldn't check stream->available() since it could return 0 over a slow-ish connection. Maybe check for -1?

Similarly, the call here:

           // write it to Stream
            bytesWritten += _tcp->write((const uint8_t *)buff, c);

is returning 0 when _tcp is a WifiClientSecure.

size_t WiFiClientSecure::write(const uint8_t *buf, size_t size) {
    if (!_ssl)
        return 0;

    int rc = ssl_write(*_ssl, buf, size);
    if (rc >= 0)
        return rc;

    return 0;
}

The last return should maybe be a -1 with errno set, or simply just returning rc. If I change this to a -1 then I see that ssl_write is always returning a negative number....

I'm not familiar with the Arduino API enough to submit a patch for these issues.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions