[Libwebsockets] SSL http client stalls on the last chunk.

Zevv libws at zevv.nl
Thu Jan 23 13:01:00 CET 2020


Here it is again with proper indenting and without the debug printf.
sorry for the noise.


diff --git a/src/lib/third_party/libwebsockets/include/libwebsockets/lws-http.h b/src/lib/third_party/libwebsockets/include/libwebsockets/lws-http.h
index e1c14e8..f3bd509 100644
--- a/src/lib/third_party/libwebsockets/include/libwebsockets/lws-http.h
+++ b/src/lib/third_party/libwebsockets/include/libwebsockets/lws-http.h
@@ -421,6 +421,21 @@ lws_hdr_copy_fragment(struct lws *wsi, char *dest, int len,
                      enum lws_token_indexes h, int frag_idx);
 
 /**
+ * lws_hdr_custom_get_name() - get the name of a custom header
+ *
+ * \param wsi: websocket connection
+ * \param n: custom header index
+ * \param name: header string (including terminating :)
+ * \param nlen: length of name
+ *
+ * This api returns -1, or the length of the name part of the header if it
+ * exists.  Lws must be built with LWS_WITH_CUSTOM_HEADERS (on by default) to
+ * use this api.
+ */
+LWS_VISIBLE LWS_EXTERN int
+lws_hdr_custom_get_name(struct lws *wsi, int n, char *name, int bufsize);
+
+/**
  * lws_hdr_custom_length() - return length of a custom header
  *
  * \param wsi: websocket connection
diff --git a/src/lib/third_party/libwebsockets/lib/roles/http/parsers.c b/src/lib/third_party/libwebsockets/lib/roles/http/parsers.c
index 6bba484..af9d69b 100644
--- a/src/lib/third_party/libwebsockets/lib/roles/http/parsers.c
+++ b/src/lib/third_party/libwebsockets/lib/roles/http/parsers.c
@@ -571,6 +571,33 @@ int lws_hdr_copy(struct lws *wsi, char *dst, int len,
 
 #if defined(LWS_WITH_CUSTOM_HEADERS)
 int
+lws_hdr_custom_get_name(struct lws *wsi, int n, char *name, int bufsize)
+{
+       ah_data_idx_t ll;
+    int i = 0;
+
+       if (!wsi->http.ah || wsi->mux_substream)
+               return -1;
+
+       ll = wsi->http.ah->unk_ll_head;
+       while (ll) {
+               if (ll >= wsi->http.ah->data_length)
+                       return -1;
+               int nlen = lws_ser_ru16be((uint8_t *)&wsi->http.ah->data[ll + UHO_NLEN]);
+               if(i == n) {
+                       int cplen = bufsize-1 < nlen ? bufsize-1 : nlen;
+                       strncpy(name, &wsi->http.ah->data[ll + UHO_NAME], cplen);
+                       name[cplen] = '\0';
+                       return cplen;
+               }
+               ll = lws_ser_ru32be((uint8_t *)&wsi->http.ah->data[ll + UHO_LL]);
+        i ++;
+       }
+
+       return -1;
+}
+
+int
 lws_hdr_custom_length(struct lws *wsi, const char *name, int nlen)
 {
        ah_data_idx_t ll;




More information about the Libwebsockets mailing list