Skip to content

Commit c7134ef

Browse files
committed
add GZIP_COMPRSSION defintion
1 parent 036fbad commit c7134ef

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ if(SENTRY_TRANSPORT_COMPRESSION)
299299
endif()
300300

301301
target_link_libraries(sentry PRIVATE ZLIB::ZLIB)
302+
303+
add_definitions(-DGZIP_COMPRESSION)
302304
endif()
303305

304306
set_property(TARGET sentry PROPERTY C_VISIBILITY_PRESET hidden)

src/sentry_transport.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#include "sentry_ratelimiter.h"
66
#include "sentry_string.h"
77

8-
#include "zlib.h"
8+
#ifdef GZIP_COMPRESSION
9+
include "zlib.h"
10+
#endif
911

1012
#define ENVELOPE_MIME "application/x-sentry-envelope"
1113
// The headers we use are: `x-sentry-auth`, `content-type`, `content-encoding`, `content-length`
@@ -150,6 +152,7 @@ sentry_transport_free(sentry_transport_t *transport)
150152
sentry_free(transport);
151153
}
152154

155+
#ifdef GZIP_COMPRESSION
153156
static bool
154157
gzipped_with_compression(const char *body, const size_t body_len,
155158
char **compressed_body, size_t *compressed_body_len)
@@ -197,6 +200,7 @@ gzipped_with_compression(const char *body, const size_t body_len,
197200
deflateEnd(&stream);
198201
return true;
199202
}
203+
#endif
200204

201205
sentry_prepared_http_request_t *
202206
sentry__prepare_http_request(sentry_envelope_t *envelope,
@@ -215,9 +219,11 @@ sentry__prepare_http_request(sentry_envelope_t *envelope,
215219
return NULL;
216220
}
217221

222+
bool compressed = false;
223+
#ifdef GZIP_COMPRESSION
218224
char *compressed_body = NULL;
219225
size_t compressed_body_len = 0;
220-
bool compressed = gzipped_with_compression(
226+
compressed = gzipped_with_compression(
221227
body, body_len, &compressed_body, &compressed_body_len);
222228
if (compressed) {
223229
if (body_owned) {
@@ -228,6 +234,7 @@ sentry__prepare_http_request(sentry_envelope_t *envelope,
228234
body_len = compressed_body_len;
229235
body_owned = true;
230236
}
237+
#endif
231238

232239
sentry_prepared_http_request_t *req
233240
= SENTRY_MAKE(sentry_prepared_http_request_t);

0 commit comments

Comments
 (0)