Skip to content

Fix WebServerSecure streamFile() #4545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 22, 2018
Merged

Conversation

earlephilhower
Copy link
Collaborator

ESP8266WebServerSecure's streamFile was using the base class' method
which did not use SSL encrypt before transmitting, leading to failure.

Add a new template method and required support for
WiFiClientSecure::write(Stream&) (using a local temp buffer since the
SSL libs do not grok Arduino Streams at all).

Fixes #4544

ESP8266WebServerSecure's streamFile was using the base class' method
which did not use SSL encrypt before transmitting, leading to failure.

Add a new template method and required support for
WiFiClientSecure::write(Stream&) (using a local temp buffer since the
SSL libs do not grok Arduino Streams at all).

Fixes esp8266#4544
countSent = write(temp, countRead);
totalSent += countSent;
}
} while ( (countSent == countRead) && (countSent > 0) );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the streaming takes a long time? wouldn't you get a wdt timeout?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Just checked the ClientContext code and matched their yield and chunk sizes. Tested against a 158KB HTTPS file transfer which took many seconds to complete.

ClientContext sends out 256 bytes at a time and gives a yield after
each chunk to ensure the WDT doesn't fire.  Mimic that behavior in
WiFiClientSecure::write(Stream&).
@devyte devyte merged commit 42f824b into esp8266:master Mar 22, 2018
@earlephilhower earlephilhower deleted the fix_wss branch March 22, 2018 14:34
bryceschober pushed a commit to bryceschober/Arduino that referenced this pull request Apr 5, 2018
* Fix WebServerSecure streamFile()

ESP8266WebServerSecure's streamFile was using the base class' method
which did not use SSL encrypt before transmitting, leading to failure.

Add a new template method and required support for
WiFiClientSecure::write(Stream&) (using a local temp buffer since the
SSL libs do not grok Arduino Streams at all).

Fixes esp8266#4544

* Match ClientContext buffer and yield() behavior

ClientContext sends out 256 bytes at a time and gives a yield after
each chunk to ensure the WDT doesn't fire.  Mimic that behavior in
WiFiClientSecure::write(Stream&).

(cherry picked from commit 42f824b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants