Skip to content

Commit

Permalink
rest_client: caseless matching when searching for Content-Type
Browse files Browse the repository at this point in the history
Also properly handle missing "Content-Type"
  • Loading branch information
liviuchircu committed May 4, 2015
1 parent 89eb9dc commit 4d651f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/rest_client/rest_cb.c
Expand Up @@ -74,7 +74,7 @@ size_t header_func(char *ptr, size_t size, size_t nmemb, void *userdata)
len = left = size * nmemb;

if (len > CONTENT_TYPE_HDR_LEN && *ptr == 'C' &&
memcmp(ptr, HTTP_HDR_CONTENT_TYPE, CONTENT_TYPE_HDR_LEN) == 0) {
strncasecmp(ptr, HTTP_HDR_CONTENT_TYPE, CONTENT_TYPE_HDR_LEN) == 0) {

ptr += CONTENT_TYPE_HDR_LEN + 1;
left -= CONTENT_TYPE_HDR_LEN + 1;
Expand Down
8 changes: 5 additions & 3 deletions modules/rest_client/rest_methods.c
Expand Up @@ -327,7 +327,7 @@ enum async_ret_code resume_async_http_req(int fd, struct sip_msg *msg, void *_pa
}

pkg_free(param->body.s);
if (param->ctype_pv)
if (param->ctype_pv && param->ctype.s)
pkg_free(param->ctype.s);
curl_easy_cleanup(param->handle);
pkg_free(param);
Expand Down Expand Up @@ -426,7 +426,8 @@ int rest_get_method(struct sip_msg *msg, char *url,
goto cleanup;
}

pkg_free(st.s);
if (st.s)
pkg_free(st.s);
}

curl_easy_cleanup(handle);
Expand Down Expand Up @@ -540,7 +541,8 @@ int rest_post_method(struct sip_msg *msg, char *url, char *body, char *ctype,
goto cleanup;
}

pkg_free(st.s);
if (st.s)
pkg_free(st.s);
}

curl_easy_cleanup(handle);
Expand Down

0 comments on commit 4d651f4

Please sign in to comment.