From 1535df6c2240920cc6d25a7c4b9354e58a9d23c4 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 10 Jul 2017 02:59:27 +0200 Subject: activation: Also print HTTP body data when communication debugging is requested --- src/activation.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/activation.c b/src/activation.c index adc5897..6232dbd 100644 --- a/src/activation.c +++ b/src/activation.c @@ -635,6 +635,34 @@ static int plist_strip_xml(char** xmlplist) return 0; } +static int idevice_activation_curl_debug_callback(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr) +{ + switch (type) { + case CURLINFO_TEXT: + fprintf(stderr, "* "); + break; + case CURLINFO_DATA_IN: + case CURLINFO_HEADER_IN: + fprintf(stderr, "< "); + break; + case CURLINFO_DATA_OUT: + case CURLINFO_HEADER_OUT: + fprintf(stderr, "> "); + break; + case CURLINFO_SSL_DATA_IN: + case CURLINFO_SSL_DATA_OUT: + return 0; + default: + return 0; + } + + fwrite(data, 1, size, stderr); + if (size > 0 && data[size-1] != '\n') { + fprintf(stderr, "\n"); + } + return 0; +} + IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_request_new(idevice_activation_client_type_t client_type, idevice_activation_request_t* request) { if (!request) @@ -1228,14 +1256,11 @@ IDEVICE_ACTIVATION_API idevice_activation_error_t idevice_activation_send_reques // enable communication debugging if (debug_level > 0) { curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); + curl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, idevice_activation_curl_debug_callback); } curl_easy_perform(handle); - if (debug_level > 0) { - fprintf(stderr, "%*s\n", (int)tmp_response->raw_content_size, tmp_response->raw_content); - } - result = idevice_activation_parse_raw_response(tmp_response); if (result != IDEVICE_ACTIVATION_E_SUCCESS) { goto cleanup; -- cgit v1.1-32-gdbae