Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions header.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,3 +707,15 @@ int sizeofencaps(ci_encaps_entity_t * e)
}
return 0;
}

const char *ci_print_icap_headers(ci_headers_list_t *h)
{
int i;
const char *header;

ci_debug_printf(1, "\n===== ICAP Headers =====\n");
for (i = 0; i < h->used; i++) {
header = h->headers[i];
ci_debug_printf(1, "ICAP header: %s\n", header);
}
}
2 changes: 2 additions & 0 deletions include/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ CI_DECLARE_FUNC(const char *) ci_headers_first_line2(ci_headers_list_t *heads, s
/*compatibility macro*/
#define ci_headers_copy_header_bytes ci_headers_pack_to_buffer

CI_DECLARE_FUNC(const char *) ci_print_icap_headers(ci_headers_list_t *heads);

/*The following headers are only used internally */
CI_DECLARE_FUNC(void) ci_headers_pack(ci_headers_list_t *heads);
CI_DECLARE_FUNC(int) ci_headers_unpack(ci_headers_list_t *heads);
Expand Down
2 changes: 2 additions & 0 deletions include/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ CI_DECLARE_FUNC(void) ci_client_library_init();

CI_DECLARE_FUNC(void) ci_client_library_release();

CI_DECLARE_FUNC(void) ci_print_http_headers(ci_request_t *req);

/** Deprecated. Use ci_connect_to declared in net_io.h instead. */
CI_DECLARE_FUNC(ci_connection_t *) ci_client_connect_to(char *servername,int port,int proto);

Expand Down
31 changes: 31 additions & 0 deletions request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1737,3 +1737,34 @@ int process_request(ci_request_t * req)

return res; /*Allow to log even the failed requests*/
}

void print_http_header(void *d, const char *head, const char *value)
{
if (!head || !*head) {
ci_debug_printf(1, "\t%s\n", value);
} else {
ci_debug_printf(1, "\t%s: %s\n", head, value);
}
}

void ci_print_http_headers(ci_request_t *req)
{
int type;
ci_headers_list_t *headers;
ci_debug_printf(1, "\n===== Request Headers =====\n");
ci_debug_printf(1, "\nICAP HEADERS:\n");
ci_headers_iterate(req->response_header, NULL, print_http_header);
ci_debug_printf(1, "\n");

if ((headers = ci_http_response_headers(req)) == NULL) {
headers = ci_http_request_headers(req);
type = ICAP_REQMOD;
} else
type = ICAP_RESPMOD;

if (headers) {
ci_debug_printf(1, "%s HEADERS:\n", ci_method_string(type));
ci_headers_iterate(headers, NULL, print_http_header);
ci_debug_printf(1, "\n");
}
}