Skip to content

Commit ab2413f

Browse files
committed
misc: update compression header
1 parent c91bcd0 commit ab2413f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/lib.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ impl ApolloTracing {
200200
}
201201
};
202202

203+
let mut client = client
204+
.post(REPORTING_URL)
205+
.header("content-type", "application/protobuf")
206+
.header("accept", "application/json")
207+
.header("X-Api-Key", &authorization_token);
208+
209+
if cfg!(feature = "compression") {
210+
client = client.header("content-encoding", "gzip");
211+
};
212+
203213
let msg = match compression::compress(msg) {
204214
Ok(result) => result,
205215
Err(e) => {
@@ -208,15 +218,7 @@ impl ApolloTracing {
208218
}
209219
};
210220

211-
let result = client
212-
.post(REPORTING_URL)
213-
.body(msg)
214-
.header("content-type", "application/protobuf")
215-
.header("content-encoding", "gzip")
216-
.header("accept", "application/json")
217-
.header("X-Api-Key", &authorization_token)
218-
.send()
219-
.await;
221+
let result = client.body(msg).send().await;
220222

221223
match result {
222224
Ok(data) => {

0 commit comments

Comments
 (0)