W3C home > Mailing lists > Public > www-lib@w3.org > April to June 2006

Store the result of GET in a file

From: <neelu_dhiman@persistent.co.in>
Date: Tue, 9 May 2006 14:04:43 +0530 (IST)
To: www-lib@w3.org
Message-Id: <20060509140443.AJF43158@mail6.persistent.co.in>

Hi friends,
I am passing an http GET request using libwww. The output of
the request is an XML file that I want to dump to some text
file. Here is the code:

//Store Groups in a Text file //
#include <w3c-libwww/WWWLib.h>
#include <w3c-libwww/WWWHTTP.h>
#include <w3c-libwww/WWWInit.h>

PRIVATE int printer (const char * fmt, va_list pArgs)
    return (vfprintf(stdout, fmt, pArgs));

PRIVATE int tracer (const char * fmt, va_list pArgs)
    return (vfprintf(stderr, fmt, pArgs));
PRIVATE int terminate_handler (HTRequest * request, HTResponse
* response, void * param, int status) 
    /* Check for status */
    HTPrint("Load resulted in status %d\n", status);
		/* we're not handling other requests */
	HTEventList_stopLoop (); 
	/* stop here */
    return HT_ERROR;

int main (int argc, char ** argv)
    HTRequest * request = HTRequest_new();
    char * url =
	char *filename="Groups";
  HTProfile_newPreemptiveClient("TestApp", "1.1");
#if 0
    HTRequest_setOutputFormat(request, WWW_RAW);
    HTRequest_addConnection(request, "close", "");
    HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL,
	if ( HTLoadToFile (url, request,filename)==YES)
		printf("Loaded in file");
		printf("Could not load");	
    return 0;

I am getting a zero length file. Please guide.
Received on Tuesday, 9 May 2006 08:38:40 UTC

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