Re: POST not working

You may use the following code snippet for your
requirement. This sample is from a CPP wrapper for
libwww.

	//strBody = "msg=<XML><DATA>...</DATA></XML>
	int HTTPRequest::send(char* sURL, char *strBody)
	{
		HTParentAnchor * src = NULL;
		src = HTTmpAnchor(NULL);
		BOOL status = NO;

		HTRequest* pRequest = HTRequest_new();
		HTRequest_setOutputFormat(pRequest,  WWW_SOURCE);
		HTRequest_addConnection(pRequest, "close", "");
		HTRequest_setMethod(pRequest, METHOD_POST);

		HTAnchor* pAnchor = HTAnchor_findAddress(sURL);
		HTAnchor_setDocument(src, strBody);
		HTAnchor_setFormat(src, WWW_FORM);
		HTAnchor_setLength(src, strlen(strBody));

		/* POST the source to the dest */
		HTChunk *pChunk = HTPostAnchorToChunk(src, pAnchor,
pRequest);

		if (!pChunk)
		{
			HTPrint("Send: Could not post the data\n");
			return -1;
		}
}

HTChunk * HTTPRequest::HTPostAnchorToChunk
(HTParentAnchor *  source,
                         HTAnchor * destination,
                         HTRequest * request)
{
	if (source && destination && request)
	{
		HTChunk * chunk = NULL;
		HTStream * target = HTStreamToChunk(request, &chunk,
0);
		HTRequest_setOutputStream(request, target);

		if (HTPostAnchor(source, destination, request) )
		  return chunk;
		else
		{
		  HTChunk_delete(chunk);
		  return NULL;
		}
	}
  	return NULL;
}


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

Received on Monday, 29 March 2004 10:06:10 UTC