Skip to content

Commit

Permalink
Fix sample event handler behaviour (#2743)
Browse files Browse the repository at this point in the history
* Don't include trailing null in gzip message body
* Use standard HTTP headers in sample evh messages
  • Loading branch information
i8-pi committed Jul 28, 2021
1 parent 696d7bf commit a2f3714
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions events/janus_sampleevh.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ static void *janus_sampleevh_handler(void *data) {
curl_easy_setopt(curl, CURLOPT_PASSWORD, backend_pwd);
}
janus_mutex_unlock(&evh_mutex);
headers = curl_slist_append(headers, "Content-Type: application/json");
/* Check if we need to compress the data */
if(compress) {
compressed_len = janus_gzip_compress(compression,
Expand All @@ -748,10 +749,8 @@ static void *janus_sampleevh_handler(void *data) {
output = NULL;
continue;
}
headers = curl_slist_append(headers, "Content-Encoding: gzip");
}
headers = curl_slist_append(headers, compress ? "Accept: application/gzip": "Accept: application/json");
headers = curl_slist_append(headers, compress ? "Content-Type: application/gzip" : "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, compress ? compressed_text : event_text);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, compress ? compressed_len : strlen(event_text));
Expand Down
2 changes: 1 addition & 1 deletion utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ size_t janus_gzip_compress(int compression, char *text, size_t tlen, char *compr
zs.zfree = Z_NULL;
zs.opaque = Z_NULL;
zs.next_in = (Bytef *)text;
zs.avail_in = (uInt)tlen+1;
zs.avail_in = (uInt)tlen;
zs.next_out = (Bytef *)compressed;
zs.avail_out = (uInt)zlen;
int res = deflateInit2(&zs, compression, Z_DEFLATED, 15 | 16, 8, Z_DEFAULT_STRATEGY);
Expand Down

0 comments on commit a2f3714

Please sign in to comment.