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)