]> prime8.dev >> repos - ttyd.git/commitdiff
http: fix libwebsockets 1.7 support
authorShuanglei Tao <tsl0922@gmail.com>
Sun, 23 Jun 2019 10:50:30 +0000 (18:50 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Sun, 23 Jun 2019 10:50:30 +0000 (18:50 +0800)
src/http.c

index 2a5d0925f6bd84858dcf310f2afa80f28ac2709b..6dfd8bf159d9cf94b33441c1c2a08e9415647b47 100644 (file)
@@ -138,9 +138,15 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, voi
                     return 1;
                 if (lws_write(wsi, buffer + LWS_PRE, p - (buffer + LWS_PRE), LWS_WRITE_HTTP_HEADERS) < 0)
                     return 1;
+#if LWS_LIBRARY_VERSION_MAJOR < 2
+                if (lws_write_http(wsi, index_html, index_html_len) < 0)
+                    return 1;
+                goto try_to_reuse;
+#else
                 pss->buffer = pss->ptr = (char *) index_html;
                 pss->len = index_html_len;
                 lws_callback_on_writable(wsi);
+#endif
             }
             break;