MOHAMED
MOHAMED

Reputation: 43548

Libcurl display log messages even the CURLOPT_VERBOSE is not activated

I'm using libcurl to send http message.

I developed the following function in which I initiate curl options and then perform a send of a http message. the option CURLOPT_VERBOSE is not activated in the following code. But when executing the following function, the received http message is displayed in the verbose. How I can fix that ?

http_lightweight_notification(char *msg_out, int msg_out_len)
{
    static CURL *n_curl;
    CURLcode res;
    struct curl_slist *chunk = NULL;
    char *url="http://192.168.1.133:8080";
    char buf[SIGNATURE_LEN + sizeof("Signature: ")] = "Signature: ";
    char *signature = buf + sizeof("Signature: ") - 1;

    if (!msg_out) return -1;
    n_curl = curl_easy_init();
    if (!n_curl) return -1;

    signature_hmac_sha1(msg_out, "anykey", signature);

    chunk = curl_slist_append(chunk, "Content-Type: text/xml; charset=utf-8");
    if (!chunk) return -1;
    chunk = curl_slist_append(chunk, "Accept:");
    if (!chunk) return -1;
    chunk = curl_slist_append(chunk, buf);
    if (!chunk) return -1;

    curl_easy_setopt(n_curl, CURLOPT_URL, url);
    curl_easy_setopt(n_curl, CURLOPT_HTTPHEADER, chunk);
    curl_easy_setopt(n_curl, CURLOPT_TIMEOUT, 30);
    curl_easy_setopt(n_curl, CURLOPT_CONNECTTIMEOUT, 30);

    curl_easy_setopt(n_curl, CURLOPT_POSTFIELDS, msg_out);
    curl_easy_setopt(n_curl, CURLOPT_POSTFIELDSIZE, (long) msg_out_len);

# if 0
    curl_easy_setopt(n_curl, CURLOPT_VERBOSE, 1L);
# endif

    res = curl_easy_perform(n_curl);
    if (chunk) {
        curl_slist_free_all(chunk);
        chunk = NULL;
    }
    curl_easy_cleanup(n_curl);
    curl_global_cleanup();

    if (res) return -1;
    return 0;
}

The verbose output is:

<html><head><title>JBossWeb/2.0.1.GA - Rapport d'erreur</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>Etat HTTP 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Rapport d'exception</p><p><b>message</b> <u></u></p><p><b>description</b> <u>Le serveur a rencontrأ� une erreur interne () qui l'a empأ�chأ� de satisfaire la requأ�te.</u></p><p><b>exception</b> <pre>org.jboss.ws.core.CommonSOAPFaultException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
        org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:93)
        org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:262)
        org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:185)
        org.openacs.ACSServlet.processRequest(ACSServlet.java:331)
        org.openacs.ACSServlet.doPost(ACSServlet.java:588)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
</pre></p><p><b>note</b> <u>La trace complأ�te de la cause mأ�re de cette erreur est disponible dans les fichiers journaux de JBossWeb/2.0.1.GA.</u></p><HR size="1" noshade="noshade"><h3>JBossWeb/2.0.1.GA</h3></body></html>

Upvotes: 0

Views: 1096

Answers (1)

Daniel Stenberg
Daniel Stenberg

Reputation: 58124

That's not the verbose output, that's the body of the content you receive.

You inhibit the content to get sent to stdout (which is the default) by setting the CURLOPT_WRITEFUNCTION to receive the data, or possibly set CURLOPT_WRITEDATA to a different FILE * handle.

Shown in the getinmemory.c example among others.

Upvotes: 1

Related Questions