[Libwebsockets] [Patch] LCCSCF_NO_FOLLOW_REDIRECT

Zevv libws at zevv.nl
Tue Jan 21 14:02:28 CET 2020


This patch adds an option to disable the following of 30X redirects
on HTTP clients.

diff --git a/src/lib/third_party/libwebsockets/include/libwebsockets/lws-client.h b/src/lib/third_party/libwebsockets/include/libwebsockets/lws-client.h
index d41a91a..fbb9e7b 100644
--- a/src/lib/third_party/libwebsockets/include/libwebsockets/lws-client.h
+++ b/src/lib/third_party/libwebsockets/include/libwebsockets/lws-client.h
@@ -57,6 +57,7 @@ enum lws_client_connect_ssl_connection_flags {
                 * HTTP/2:   always possible... uses parallel streams
                 */
        LCCSCF_MUXABLE_STREAM                   = (1 << 17),
+       LCCSCF_NO_FOLLOW_REDIRECT       = (1 << 18),
 };
 
 /** struct lws_client_connect_info - parameters to connect with when using
diff --git a/src/lib/third_party/libwebsockets/lib/core-net/connect.c b/src/lib/third_party/libwebsockets/lib/core-net/connect.c
index 6f2a619..b8dcb0f 100644
--- a/src/lib/third_party/libwebsockets/lib/core-net/connect.c
+++ b/src/lib/third_party/libwebsockets/lib/core-net/connect.c
@@ -151,6 +151,7 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)
 
        wsi->protocol = &wsi->vhost->protocols[0];
        wsi->client_pipeline = !!(i->ssl_connection & LCCSCF_PIPELINE);
+       wsi->client_no_follow_redirect = !!(i->ssl_connection & LCCSCF_NO_FOLLOW_REDIRECT);
 
        /*
         * PHASE 5: handle external user_space now, generic alloc is done in
diff --git a/src/lib/third_party/libwebsockets/lib/core-net/private-lib-core-net.h b/src/lib/third_party/libwebsockets/lib/core-net/private-lib-core-net.h
index 3a3a199..c791615 100644
--- a/src/lib/third_party/libwebsockets/lib/core-net/private-lib-core-net.h
+++ b/src/lib/third_party/libwebsockets/lib/core-net/private-lib-core-net.h
@@ -800,6 +800,7 @@ struct lws {
        unsigned int                    client_mux_substream:1;
        unsigned int                    client_mux_migrated:1;
        unsigned int                    client_subsequent_mime_part:1;
+       unsigned int                    client_no_follow_redirect:1;
 #endif
 
 #ifdef _WIN32
diff --git a/src/lib/third_party/libwebsockets/lib/roles/http/client/client-http.c b/src/lib/third_party/libwebsockets/lib/roles/http/client/client-http.c
index 3f02067..01da328 100644
--- a/src/lib/third_party/libwebsockets/lib/roles/http/client/client-http.c
+++ b/src/lib/third_party/libwebsockets/lib/roles/http/client/client-http.c
@@ -799,7 +799,7 @@ lws_client_interpret_server_handshake(struct lws *wsi)
        if (ah)
                ah->http_response = n;
 
-       if (
+       if (!wsi->client_no_follow_redirect &&
 #if defined(LWS_WITH_HTTP_PROXY)
            !wsi->http.proxy_clientside &&
 #endif



More information about the Libwebsockets mailing list