diff --git a/lib/core-net/output.c b/lib/core-net/output.c index 2de4a30a8..e7d05562a 100644 --- a/lib/core-net/output.c +++ b/lib/core-net/output.c @@ -250,6 +250,7 @@ lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len) lws_stats_atomic_bump(context, pt, LWSSTATS_C_API_READ, 1); + errno = 0; if (lws_wsi_is_udp(wsi)) { #if !defined(LWS_WITH_ESP32) && !defined(LWS_PLAT_OPTEE) wsi->udp->salen = sizeof(wsi->udp->sa); @@ -264,6 +265,13 @@ lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len) if (!n && wsi->unix_skt) return LWS_SSL_CAPABLE_ERROR; + /* + * See https://libwebsockets.org/ + * pipermail/libwebsockets/2019-March/007857.html + */ + if (!n) + return LWS_SSL_CAPABLE_ERROR; + if (wsi->vhost) wsi->vhost->conn_stats.rx += n; lws_stats_atomic_bump(context, pt, LWSSTATS_B_READ, n); diff --git a/minimal-examples/http-client/minimal-http-client/minimal-http-client.c b/minimal-examples/http-client/minimal-http-client/minimal-http-client.c index 4382647bd..d8ce24212 100644 --- a/minimal-examples/http-client/minimal-http-client/minimal-http-client.c +++ b/minimal-examples/http-client/minimal-http-client/minimal-http-client.c @@ -146,7 +146,8 @@ int main(int argc, const char **argv) memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */ i.context = context; - i.ssl_connection = LCCSCF_USE_SSL; + if (!lws_cmdline_option(argc, argv, "-n")) + i.ssl_connection = LCCSCF_USE_SSL; if (lws_cmdline_option(argc, argv, "-l")) { i.port = 7681; @@ -160,6 +161,9 @@ int main(int argc, const char **argv) if (lws_cmdline_option(argc, argv, "--h1")) i.alpn = "http/1.1"; + if ((p = lws_cmdline_option(argc, argv, "-p"))) + i.port = atoi(p); + i.path = "/"; i.host = i.address; i.origin = i.address;