diff options
Diffstat (limited to 'lib/sendf.c')
-rw-r--r-- | lib/sendf.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/sendf.c b/lib/sendf.c index d0688ec21..8886b8372 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -454,7 +454,9 @@ CURLcode Curl_client_write(struct connectdata *conn, return CURLE_OK; } +#ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif /* * Internal read-from-socket function. This is meant to deal with plain @@ -563,6 +565,7 @@ static int showit(struct SessionHandle *data, curl_infotype type, #ifdef CURL_DOES_CONVERSIONS char buf[BUFSIZE+1]; + int conv_size; switch(type) { case CURLINFO_HEADER_OUT: @@ -572,8 +575,24 @@ static int showit(struct SessionHandle *data, curl_infotype type, size = BUFSIZE; /* truncate if necessary */ buf[BUFSIZE] = '\0'; } + conv_size = size; memcpy(buf, ptr, size); - Curl_convert_from_network(data, buf, size); + /* Special processing is needed for this block if it + * contains both headers and data (separated by CRLFCRLF). + * We want to convert just the headers, leaving the data as-is. + */ + if(size > 4) { + int i; + for(i = 0; i < size-4; i++) { + if(memcmp(&buf[i], "\x0d\x0a\x0d\x0a", 4) == 0) { + /* convert everthing through this CRLFCRLF but no further */ + conv_size = i + 4; + break; + } + } + } + + Curl_convert_from_network(data, buf, conv_size); /* Curl_convert_from_network calls failf if unsuccessful */ /* we might as well continue even if it fails... */ ptr = buf; /* switch pointer to use my buffer instead */ @@ -594,6 +613,12 @@ static int showit(struct SessionHandle *data, curl_infotype type, case CURLINFO_HEADER_IN: fwrite(s_infotype[type], 2, 1, data->set.err); fwrite(ptr, size, 1, data->set.err); +#ifdef CURL_DOES_CONVERSIONS + if(size != conv_size) { + /* we had untranslated data so we need an explicit newline */ + fwrite("\n", 1, 1, data->set.err); + } +#endif break; default: /* nada */ break; |