Skip to content

Commit 3e74fd5

Browse files
committed
reuse body/_owned
1 parent 9278cb4 commit 3e74fd5

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

src/sentry_transport.c

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,14 @@ sentry__prepare_http_request(sentry_envelope_t *envelope,
174174
if (compressed) {
175175
if (body_owned) {
176176
sentry_free(body);
177-
body = NULL;
178-
body_owned = false;
179177
}
178+
body = compressed_body;
179+
body_len = compressed_body_len;
180180
}
181181

182182
sentry_prepared_http_request_t *req
183183
= SENTRY_MAKE(sentry_prepared_http_request_t);
184184
if (!req) {
185-
if (compressed) {
186-
sentry_free(compressed_body);
187-
}
188185
if (body_owned) {
189186
sentry_free(body);
190187
}
@@ -194,9 +191,6 @@ sentry__prepare_http_request(sentry_envelope_t *envelope,
194191
sizeof(sentry_prepared_http_header_t) * MAX_HTTP_HEADERS);
195192
if (!req->headers) {
196193
sentry_free(req);
197-
if (compressed) {
198-
sentry_free(compressed_body);
199-
}
200194
if (body_owned) {
201195
sentry_free(body);
202196
}
@@ -224,21 +218,11 @@ sentry__prepare_http_request(sentry_envelope_t *envelope,
224218

225219
h = &req->headers[req->headers_len++];
226220
h->key = "content-length";
227-
if (compressed) {
228-
h->value = sentry__int64_to_string((int64_t)compressed_body_len);
229-
} else {
230-
h->value = sentry__int64_to_string((int64_t)body_len);
231-
}
221+
h->value = sentry__int64_to_string((int64_t)body_len);
232222

233-
if (compressed) {
234-
req->body = compressed_body;
235-
req->body_len = compressed_body_len;
236-
req->body_owned = true;
237-
} else {
238-
req->body = body;
239-
req->body_len = body_len;
240-
req->body_owned = body_owned;
241-
}
223+
req->body = body;
224+
req->body_len = body_len;
225+
req->body_owned = body_owned;
242226

243227
return req;
244228
}

0 commit comments

Comments
 (0)