webclient: Don't call the sink callback if no data is available

This happened frequently for me with Docker Desktop's
/var/run/docker.sock on macOS.
But I believe it can happen on other environments, even with TCP.

Alternatively, this case can be handled by the callback
implementations.  But it's simpler to handle the corner case here.
This commit is contained in:
YAMAMOTO Takashi 2021-01-14 12:25:05 +09:00 committed by Xiang Xiao
parent 1131cbe14d
commit ee1f4fdcdb

View File

@ -982,7 +982,11 @@ int webclient_perform(FAR struct webclient_context *ctx)
* received file.
*/
if (ctx->sink_callback)
if (ws->offset == ws->datend)
{
/* We don't have data to give to the client yet. */
}
else if (ctx->sink_callback)
{
ret = ctx->sink_callback(&ws->buffer, ws->offset,
ws->datend, &ws->buflen,