W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2004

Re: POST not working

From: Girish S <girishpage@yahoo.com>
Date: Mon, 29 Mar 2004 06:57:30 -0800 (PST)
Message-ID: <20040329145730.49606.qmail@web14008.mail.yahoo.com>
To: www-lib@w3.org

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

This archive was generated by hypermail 2.3.1 : Tuesday, 18 February 2014 13:20:04 UTC