cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problem with Header-In ( Debug callback )

From: Eugene Kravchenko <eugene22_at_mail.ru>
Date: Wed, 30 Nov 2005 12:22:36 +0300

Hi.

Problem:
when i receive multiline CURLINFO_HEADER_IN data ( ftp-responces via CURLOPT_DEBUGFUNCTION ) i have a problem with content of this, for example:

1-st responce:
Recv data:
<list of ftp-server>

2:
Recv header:
226-Maximum disk quota limited to 32768 kBytes
Used disk quota 20718 kBytes, available 12049 kBytes
226 Transfer complete.
<... HERE LIST of ftp-server AGAIN...>

3:
Recv header:
Used disk quota 20718 kBytes, available 12049 kBytes
226 Transfer complete.
<... HERE LIST of ftp-server AGAIN...>

4:
Recv header:
226 Transfer complete.
<... HERE LIST of ftp-server AGAIN...>

Best regards
-------------------------------------------------------------------------------
Full LOG:

11:46:33 078 (ftp_reader.c:693) 'GenericFtpReader'> == Info: About to connect() to 218.78.37.36 port 21
11:46:33 093 (ftp_reader.c:693) 'GenericFtpReader'> == Info: Trying 218.78.37.36...
11:46:40 484 (ftp_reader.c:693) 'GenericFtpReader'> == Info: connected
11:46:40 484 (ftp_reader.c:693) 'GenericFtpReader'> == Info: Connected to 218.78.37.36 (218.78.37.36) port 21
11:46:40 781 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header: 220 Serv-U FTP Server v6.0 for WinSock ready...
11:46:40 781 (ftp_reader.c:718) 'GenericFtpReader'> => Send header: USER *****
11:46:41 031 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header: 331 User name okay, need password. ck ready...
11:46:41 031 (ftp_reader.c:718) 'GenericFtpReader'> => Send header: PASS *****
11:46:41 250 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header: 230 User logged in, proceed. ord.
11:46:41 250 (ftp_reader.c:718) 'GenericFtpReader'> => Send header: PWD
11:46:41 484 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header: 257 "/" is current directory. rd.
11:46:41 484 (ftp_reader.c:693) 'GenericFtpReader'> == Info: Entry path is '/'
11:46:41 484 (ftp_reader.c:718) 'GenericFtpReader'> => Send header: PASV
11:46:41 484 (ftp_reader.c:693) 'GenericFtpReader'> == Info: Connect data stream passively
11:46:41 718 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header: 227 Entering Passive Mode (217,76,34,38,10,69)
11:46:41 718 (ftp_reader.c:693) 'GenericFtpReader'> == Info: Trying 217.76.34.38...
11:46:41 921 (ftp_reader.c:693) 'GenericFtpReader'> == Info: connected
11:46:41 921 (ftp_reader.c:693) 'GenericFtpReader'> == Info: Connecting to 217.76.34.38 (217.76.34.38) port 2629
11:46:41 921 (ftp_reader.c:718) 'GenericFtpReader'> => Send header: TYPE A
11:46:42 156 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header: 200 Type set to A. Mode (217,76,34,38,10,69)
11:46:42 156 (ftp_reader.c:718) 'GenericFtpReader'> => Send header: LIST
11:46:42 484 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header: 150 Opening ASCII mode data connection for /bin/ls.
11:46:42 484 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv data: <... HERE LIST of ftp-server...>
11:46:42 484 (ftp_reader.c:693) 'GenericFtpReader'> == Info: Remembering we are in dir /
11:46:42 875 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header:

226-Maximum disk quota limited to 32768 kBytes
Used disk quota 20718 kBytes, available 12049 kBytes
226 Transfer complete.
<... HERE LIST of ftp-server AGAIN...>

11:46:42 875 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header:
Used disk quota 20718 kBytes, available 12049 kBytes
226 Transfer complete.
<... HERE LIST of ftp-server AGAIN !!!...>

11:46:42 875 (ftp_reader.c:718) 'GenericFtpReader'> <= Recv header:
226 Transfer complete.
<... HERE LIST of ftp-server AGAIN !!!!!!...>

11:46:42 875 (ftp_reader.c:693) 'GenericFtpReader'> == Info: Connection #0 to host 218.78.37.36 left intact

----------------------------------------------------------------------------------------
cURL options:

    curl_easy_setopt( curlheader, CURLOPT_VERBOSE, TRUE );
    curl_easy_setopt( curlheader, CURLOPT_FTP_USE_EPSV, 0 );
    curl_easy_setopt( curlheader, CURLOPT_FTP_RESPONSE_TIMEOUT, 10 );
    curl_easy_setopt( curlheader, CURLOPT_HEADER, 0 );
    curl_easy_setopt( curlheader, CURLOPT_NOBODY, 0);
    curl_easy_setopt( curlheader, CURLOPT_DEBUGFUNCTION, CurlTrace );

----------------------------------------------------------------------------------------
Debug function is:

int CurlTrace(
    CURL *handle,
    curl_infotype type,
    unsigned char *data,
    size_t size,
    void *userp
){
    struct data *config = (struct data *)userp;
    char text[1024] = "";

    switch ( type ) {
    case CURLINFO_TEXT:
        strcpyz( text, "== Info: \r\n", sizeof( text ) );
        strncatz( text, data, sizeof( text ) );
        LOG( LMG_INFO, text);
    default:
        return 0;

    case CURLINFO_HEADER_OUT:
        strcpyz(text, "=> Send header: \r\n", sizeof( text ) );
        break;
    case CURLINFO_DATA_OUT:
        strcpyz(text, "=> Send data: \r\n", sizeof( text ) );
        break;
    case CURLINFO_HEADER_IN:
        strcpyz(text, "<= Recv header: \r\n", sizeof( text ) );
        break;
    case CURLINFO_DATA_IN:
        strcpyz(text, "<= Recv data: \r\n", sizeof( text ) );
        break;
    case CURLINFO_SSL_DATA_IN:
        strcpyz(text, "<= Recv SSL data: \r\n", sizeof( text ) );
        break;
    case CURLINFO_SSL_DATA_OUT:
        strcpyz(text, "<= Send SSL data: \r\n", sizeof( text ) );
        break;
    }

    strncatz( text, data, sizeof( text ) );
    LOG( LMG_INFO, text );

    return ( 0 );
}
----------------------------------------------------------------------------------------
Received on 2005-11-30