posting a request to a netscape server

Aim : writing a client in C++ to retreive CA(certificate authority)
certificate from a netscape server  using Libwww.

Till now i was able to successfully load the certificate by sending the
foll. request to netscape server using the MFC functions CHTTPConnection &.
CHTTPFile:

request sring:
    	op=displayIND&withCertChain=no&navigatorFormat=no&submit=Submit


Query:
Now , i want to make use of LibWWW for eactly the same behaviour.
I am passing the above info. using LibWWW function
HTPostFormAnchorToChunk(...) by creating HTAssocList of the individual
fields &  i am getting a null data with the foll.  command line:

http://certserver/getCAChain op=displayIND withCertChain=no
navigatorFormat=no submit=Submit

but surprisingly i am getting desired data if command line is changed to

http://certserver/getCAChain op=displayIND 

& my code is:

//////////////////////////////////////////
int main (int argc, char ** argv)
{
    HTRequest * request = NULL;
    HTAnchor * anchor = NULL;
    HTAssocList * formfields = NULL;
    char * uri = NULL;
    /* Create a new premptive client */
     HTProfile_newNoCacheClient("myApp", "1.0");
    /* Need our own trace and print functions */
    HTPrint_setCallback(printer);
    HTTrace_setCallback(tracer);

     /* Get trace messages */
    HTSetTraceMessageMask("sop");

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

    /* Set the timeout for long we are going to wait for a response */
    HTHost_setEventTimeout(200000);
    /* Handle command line args */
    if (argc >= 2) {
	int arg;
	uri = argv[1];
	for (arg=2; arg<argc; arg++) {
	    char * string = argv[arg];
	    
	    /* Create a list to hold the form arguments */
	    if (!formfields) formfields = HTAssocList_new();

	    /* Parse the content and add it to the association list */
	    HTParseFormInput(formfields, string);
	}
    }

    if (uri && formfields) {

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

	/* Set the default output to "asis" */
	HTRequest_setOutputFormat(request, WWW_SOURCE);

	/* Get an anchor object for the URI */
	anchor = HTAnchor_findAddress(uri);
	/* Post the data and get the result in a chunk */
	result = HTPostFormAnchorToChunk(formfields, anchor, request);

	/* Clean up the form fields */
	HTAssocList_delete(formfields);

	/* Go into the event loop... */
	HTEventList_loop(request);

    } else {
	HTPrint("Type the URI to post to and the arguments for the POST
operation. Encode spaces as '+'\n");
	HTPrint("\t%s <uri> 'a=1' 'b=+2+' 'c=3 ...'\n", argv[0]);
    }

    return 0;
}
///////////////////////////////////////

why is taht if i  pass only the single field op=displayIND, i get the valid
data....???????
How should i make my request work with the complete string..... i.e what if
i need to pass more than two form inputs......???????


thanx 
meenakshi

Received on Friday, 5 May 2000 18:08:24 UTC