From b09b416b1ddcaf36eb2718e43c0e7a5f40352e85 Mon Sep 17 00:00:00 2001 From: Zevv Date: Tue, 21 Jan 2020 13:27:36 +0000 Subject: [PATCH] http client: add flag to disable redir follow --- include/libwebsockets/lws-client.h | 1 + lib/core-net/connect.c | 2 ++ lib/core-net/private-lib-core-net.h | 1 + lib/roles/http/client/client-http.c | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/libwebsockets/lws-client.h b/include/libwebsockets/lws-client.h index d41a91a76..7c78d54cc 100644 --- a/include/libwebsockets/lws-client.h +++ b/include/libwebsockets/lws-client.h @@ -47,6 +47,7 @@ enum lws_client_connect_ssl_connection_flags { LCCSCF_H2_MANUAL_RXFLOW = (1 << 9), LCCSCF_HTTP_MULTIPART_MIME = (1 << 10), LCCSCF_HTTP_X_WWW_FORM_URLENCODED = (1 << 11), + LCCSCF_HTTP_NO_FOLLOW_REDIRECT = (1 << 12), LCCSCF_PIPELINE = (1 << 16), /**< Serialize / pipeline multiple client connections diff --git a/lib/core-net/connect.c b/lib/core-net/connect.c index 371f196ac..700d0c2c6 100644 --- a/lib/core-net/connect.c +++ b/lib/core-net/connect.c @@ -158,6 +158,8 @@ 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_HTTP_NO_FOLLOW_REDIRECT); /* * PHASE 5: handle external user_space now, generic alloc is done in diff --git a/lib/core-net/private-lib-core-net.h b/lib/core-net/private-lib-core-net.h index d43547b09..a4e02f679 100644 --- a/lib/core-net/private-lib-core-net.h +++ b/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/lib/roles/http/client/client-http.c b/lib/roles/http/client/client-http.c index d88611dce..19aa85785 100644 --- a/lib/roles/http/client/client-http.c +++ b/lib/roles/http/client/client-http.c @@ -802,7 +802,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