From 7b10217810e48c9a90226c760bdb47a03e62269e Mon Sep 17 00:00:00 2001 From: 0x501D Date: Mon, 17 Aug 2020 12:36:09 +0300 Subject: [PATCH] core: fix ic_get_content_len --- libicap.h | 3 ++- src/ic_core.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libicap.h b/libicap.h index dd3ead2..dc9de91 100644 --- a/libicap.h +++ b/libicap.h @@ -52,7 +52,8 @@ int ic_get_status_code(ic_query_t *q); const char *ic_get_icap_hdr(ic_query_t *q); const char *ic_get_req_hdr(ic_query_t *q); const char *ic_get_resp_hdr(ic_query_t *q); -uint64_t ic_get_content_len(ic_query_t *q); +/** @return -1 if ERROR */ +int ic_get_content_len(ic_query_t *q, uint64_t *len); /** @return NULL if ERROR */ const char *ic_get_content(ic_query_t *q, size_t *len, int *err); diff --git a/src/ic_core.c b/src/ic_core.c index e0d8211..ad69358 100644 --- a/src/ic_core.c +++ b/src/ic_core.c @@ -1618,15 +1618,17 @@ IC_EXPORT const char *ic_get_icap_hdr(ic_query_t *q) return icap->srv.icap_hdr; } -IC_EXPORT uint64_t ic_get_content_len(ic_query_t *q) +IC_EXPORT int ic_get_content_len(ic_query_t *q, uint64_t *len) { ic_query_int_t *icap = ic_int_query(q); - if (!icap) { - return NULL; + if (!icap || !len) { + return -1; } - return icap->cl.content_len; + *len = icap->cl.content_len; + + return 0; } IC_EXPORT const char *ic_get_content(ic_query_t *q, size_t *len, int *err)