mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 09:18:55 +00:00
Merge pull request #487 from driskell/debugging
Split header debugging onto multiple lines for easier reading
This commit is contained in:
commit
cca217f613
43
src/curl.cpp
43
src/curl.cpp
@ -1501,19 +1501,42 @@ int S3fsCurl::CurlDebugFunc(CURL* hcurl, curl_infotype type, char* data, size_t
|
|||||||
}
|
}
|
||||||
switch(type){
|
switch(type){
|
||||||
case CURLINFO_TEXT:
|
case CURLINFO_TEXT:
|
||||||
|
// Swap tab indentation with spaces so it stays pretty in syslog
|
||||||
|
int indent;
|
||||||
|
indent = 0;
|
||||||
|
while (*data == '\t' && size > 0) {
|
||||||
|
indent += 4;
|
||||||
|
size--;
|
||||||
|
data++;
|
||||||
|
}
|
||||||
|
S3FS_PRN_CURL("* %*s%.*s", indent, "", (int)size, data);
|
||||||
|
break;
|
||||||
case CURLINFO_HEADER_IN:
|
case CURLINFO_HEADER_IN:
|
||||||
case CURLINFO_HEADER_OUT:
|
case CURLINFO_HEADER_OUT:
|
||||||
char* buff;
|
size_t length, remaining;
|
||||||
if(NULL == (buff = reinterpret_cast<char*>(malloc(size + 2 + 1)))){
|
int newline;
|
||||||
// could not allocation memory
|
char* p;
|
||||||
S3FS_PRN_CRIT("could not allocate memory");
|
|
||||||
break;
|
// Print each line individually for tidy output
|
||||||
|
remaining = size;
|
||||||
|
p = data;
|
||||||
|
do {
|
||||||
|
char* eol = (char*)memchr(p, '\n', remaining);
|
||||||
|
newline = 0;
|
||||||
|
if (eol == NULL) {
|
||||||
|
eol = (char*)memchr(p, '\r', remaining);
|
||||||
|
} else if (eol > p && *(eol - 1) == '\r') {
|
||||||
|
newline++;
|
||||||
}
|
}
|
||||||
buff[size + 2] = '\0';
|
if (eol != NULL) {
|
||||||
sprintf(buff, "%c ", (CURLINFO_TEXT == type ? '*' : CURLINFO_HEADER_IN == type ? '<' : '>'));
|
newline++;
|
||||||
memcpy(&buff[2], data, size);
|
eol++;
|
||||||
S3FS_PRN_CURL("%s", buff); // no blocking
|
}
|
||||||
free(buff);
|
length = eol - p;
|
||||||
|
S3FS_PRN_CURL("%c %.*s", CURLINFO_HEADER_IN == type ? '<' : '>', (int)length - newline, p);
|
||||||
|
remaining -= length;
|
||||||
|
p = eol;
|
||||||
|
} while (p != NULL && remaining > 0);
|
||||||
break;
|
break;
|
||||||
case CURLINFO_DATA_IN:
|
case CURLINFO_DATA_IN:
|
||||||
case CURLINFO_DATA_OUT:
|
case CURLINFO_DATA_OUT:
|
||||||
|
Loading…
Reference in New Issue
Block a user