W3C home > Mailing lists > Public > www-lib@w3.org > October to December 2000


From: Cristian Valdebenito <crvabch@entelchile.net>
Date: Mon, 27 Nov 2000 13:11:09 -0400
Message-ID: <3A2295AD.C0B72922@entelchile.net>
To: www-lib@w3.org
Hi all,
 I'm Cristian Valdebenito  Project Manager from Banco de Chile and we
work in a project where using the libwww.    We need make a POST on a
server web, and for this we are guie with following example :

int main (int argc, char ** argv)
    HTRequest * request = NULL;
    HTParentAnchor * src = NULL;
    HTAnchor * dst = NULL;
    char * dst_str = NULL;
    char * data = NULL;
    BOOL status = NO;

    /* Create a new premptive client */
    HTProfile_newNoCacheClient("libwww-POST", "1.0");

    /* Need our own trace and print functions */

    /* Add our own filter to update the history list */
    HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL,

    /* Handle command line args */
    if (argc >= 3) {
        dst_str = argv[1];
        data = argv[2];
    } else {
        HTPrint("Type the URI of the destination you want to POST to and
the contents that you want to post.\n");
        HTPrint("\t%s <destination> <data>\n", argv[0]);
        HTPrint("For example, %s http://myserver/destination.html \"This
is some testdata\"\n",
        return -1;

    if (data && *data && dst_str && *dst_str) {

        /* Make source relative to where we are */
        char * cwd = HTGetCurrentDirectoryURL();

        HTPrint("Posting to %s\n", dst_str);

        /* Create a request */
        request = HTRequest_new();

        /* Get an anchor object for the destination URI */
        dst = HTAnchor_findAddress(dst_str);

        ** Dream up a source anchor (an editor can for example use
        ** After creation we associate the data that we want to post and

        ** set some metadata about what the data is. More formats can be
        ** ../src/HTFormat.html
        src = HTTmpAnchor(NULL);
        HTAnchor_setDocument(src, data);
        HTAnchor_setFormat(src, WWW_PLAINTEXT);

        ** If not posting to an HTTP/1.1 server then content length MUST
        ** there. If HTTP/1.1 then it doesn't matter as we just use
        ** encoding under the covers
        HTAnchor_setLength(src, strlen(data));

        /* POST the source to the dest */
        status = HTPostAnchor(src, dst, request);

        /* We don't need these anymore */

        /* Go into the event loop... */
        if (status == YES) HTEventList_loop(request);


    return 0;

But this example ask a file name for save the response.  However, we
need store the server response
on a memory, or a buffer for process its content.
  If you can help us, please answer me.

Thank and I apoligize for my english
Received on Monday, 27 November 2000 12:12:18 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:53 UTC