diff --git a/src/common/networking/networking.h b/src/common/networking/networking.h index ca856e2e0..0a86d6c68 100644 --- a/src/common/networking/networking.h +++ b/src/common/networking/networking.h @@ -25,7 +25,7 @@ typedef struct FFNetworkingState { uint32_t timeout; bool ipv6; - bool compression; + bool compression; // if true, HTTP content compression will be enabled if supported } FFNetworkingState; const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers); diff --git a/src/common/networking/networking_linux.c b/src/common/networking/networking_linux.c index 1f3881ae4..1f9dc6fb3 100644 --- a/src/common/networking/networking_linux.c +++ b/src/common/networking/networking_linux.c @@ -283,22 +283,29 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho { FF_DEBUG("Preparing to send HTTP request: host=%s, path=%s", host, path); - // Initialize with compression disabled by default - state->compression = false; - - #ifdef FF_HAVE_ZLIB - const char* zlibError = ffNetworkingLoadZlibLibrary(); - // Only enable compression if zlib library is successfully loaded - if (zlibError == NULL) + if (state->compression) { - state->compression = true; - FF_DEBUG("Successfully loaded zlib library, compression enabled"); - } else { - FF_DEBUG("Failed to load zlib library, compression disabled: %s", zlibError); + FF_DEBUG("Compression enabled, checking if zlib is available"); + + #ifdef FF_HAVE_ZLIB + const char* zlibError = ffNetworkingLoadZlibLibrary(); + // Only enable compression if zlib library is successfully loaded + if (zlibError == NULL) + { + FF_DEBUG("Successfully loaded zlib library, compression enabled"); + } else { + FF_DEBUG("Failed to load zlib library, compression disabled: %s", zlibError); + state->compression = false; + } + #else + FF_DEBUG("zlib not supported at build time, compression disabled"); + state->compression = false; + #endif + } + else + { + FF_DEBUG("Compression disabled"); } - #else - FF_DEBUG("zlib not supported at build time, compression disabled"); - #endif const char* initResult = initNetworkingState(state, host, path, headers); if (initResult != NULL) { diff --git a/src/common/networking/networking_windows.c b/src/common/networking/networking_windows.c index 9a61b7353..3e353167d 100644 --- a/src/common/networking/networking_windows.c +++ b/src/common/networking/networking_windows.c @@ -49,22 +49,27 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho { FF_DEBUG("Preparing to send HTTP request: host=%s, path=%s", host, path); - // Initialize with compression disabled by default - state->compression = false; - - #ifdef FF_HAVE_ZLIB - const char* zlibError = ffNetworkingLoadZlibLibrary(); - // Only enable compression if zlib library is successfully loaded - if (zlibError == NULL) + if (state->compression) { - state->compression = true; - FF_DEBUG("Successfully loaded zlib library, compression enabled"); - } else { - FF_DEBUG("Failed to load zlib library, compression disabled: %s", zlibError); + #ifdef FF_HAVE_ZLIB + const char* zlibError = ffNetworkingLoadZlibLibrary(); + // Only enable compression if zlib library is successfully loaded + if (zlibError == NULL) + { + FF_DEBUG("Successfully loaded zlib library, compression enabled"); + } else { + FF_DEBUG("Failed to load zlib library, compression disabled: %s", zlibError); + state->compression = false; + } + #else + FF_DEBUG("zlib not supported at build time, compression disabled"); + state->compression = false; + #endif + } + else + { + FF_DEBUG("Compression disabled"); } - #else - FF_DEBUG("zlib not supported at build time, compression disabled"); - #endif static WSADATA wsaData; if (wsaData.wVersion == 0) diff --git a/src/detection/publicip/publicip.c b/src/detection/publicip/publicip.c index fd5bed232..1c952415b 100644 --- a/src/detection/publicip/publicip.c +++ b/src/detection/publicip/publicip.c @@ -19,7 +19,10 @@ void ffPreparePublicIp(FFPublicIpOptions* options) state->ipv6 = options->ipv6; if (options->url.length == 0) + { + state->compression = true; *status = ffNetworkingSendHttpRequest(state, options->ipv6 ? "v6.ipinfo.io" : "ipinfo.io", "/json", NULL); + } else { FF_STRBUF_AUTO_DESTROY host = ffStrbufCreateCopy(&options->url);