Skip to content

Commit 28100cb

Browse files
committed
rename vars and improve code logic
1 parent 5b624f9 commit 28100cb

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,12 @@ if(SENTRY_TRANSPORT_COMPRESSION)
298298
find_package(ZLIB REQUIRED)
299299
endif()
300300

301+
if(SENTRY_BACKEND_CRASHPAD)
302+
set(CRASHPAD_ZLIB_SYSTEM ON CACHE BOOL "Force CRASHPAD_ZLIB_SYSTEM when enabling transport compression" FORCE)
303+
endif()
304+
301305
target_link_libraries(sentry PRIVATE ZLIB::ZLIB)
302-
add_definitions(-DSENTRY_GZIPPED_COMPRESSION)
306+
target_compile_definitions(sentry PRIVATE SENTRY_TRANSPORT_COMPRESSION)
303307
endif()
304308

305309
set_property(TARGET sentry PROPERTY C_VISIBILITY_PRESET hidden)

src/sentry_transport.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
#include "sentry_ratelimiter.h"
66
#include "sentry_string.h"
77

8-
#ifdef SENTRY_GZIPPED_COMPRESSION
8+
#ifdef SENTRY_TRANSPORT_COMPRESSION
99
# include "zlib.h"
1010
#endif
1111

12-
#define ENVELOPE_MIME "application/x-sentry-envelope"
12+
#ifdef SENTRY_TRANSPORT_COMPRESSION
1313
// The headers we use are: `x-sentry-auth`, `content-type`, `content-encoding`,
1414
// `content-length`
1515
#define MAX_HTTP_HEADERS 4
16+
#else
17+
// The headers we use are: `x-sentry-auth`, `content-type`, `content-length`
18+
#define MAX_HTTP_HEADERS 3
19+
#endif
1620

1721
typedef struct sentry_transport_s {
1822
void (*send_envelope_func)(sentry_envelope_t *envelope, void *state);
@@ -153,7 +157,7 @@ sentry_transport_free(sentry_transport_t *transport)
153157
sentry_free(transport);
154158
}
155159

156-
#ifdef SENTRY_GZIPPED_COMPRESSION
160+
#ifdef SENTRY_TRANSPORT_COMPRESSION
157161
static bool
158162
gzipped_with_compression(const char *body, const size_t body_len,
159163
char **compressed_body, size_t *compressed_body_len)
@@ -221,7 +225,7 @@ sentry__prepare_http_request(sentry_envelope_t *envelope,
221225
}
222226

223227
bool compressed = false;
224-
#ifdef SENTRY_GZIPPED_COMPRESSION
228+
#ifdef SENTRY_TRANSPORT_COMPRESSION
225229
char *compressed_body = NULL;
226230
size_t compressed_body_len = 0;
227231
compressed = gzipped_with_compression(

0 commit comments

Comments
 (0)