Using deflate encoding with libwww

Hi,
I'm writing a client application that uses HTTP for posting data to my
application server and getting back responses. I'd like to have both the
requests and responses compressed using deflate.
The problem is that when I naively call
HTAnchor_addEncoding(src,WWW_CODING_DEFLATE), the request header
"Content-encoding: deflate" is added, but I can see that the posted data
isn't really compressed, and is sent as is.
So the question is - how do I plug the deflate encoder to the request? Or do
I have to compress the request myself prior to posting it?
Bellow is the code I'm currently using for testing this.

Thanks a lot,
Yaniv Ben-Yosef.



int CHttpRequester::PostRequest(const char *addr, char *data, int data_size)
{
    HTRequest * request = NULL;
    HTParentAnchor * src = NULL;
    HTAnchor * dst = NULL;
    BOOL status = NO;

    if (data && *data && addr && *addr) {
	HTTrace("Posting to %s\n", data);

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

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

	/*
	** Dream up a source anchor (an editor can for example use this).
	** After creation we associate the data that we want to post and
	** set some metadata about what the data is. More formats can be found
	** ../src/HTFormat.html
	*/
	src = HTTmpAnchor(NULL);
	HTAnchor_setDocument(src, data);
	HTAnchor_setFormat(src, WWW_BINARY);
	HTAnchor_addEncoding(src,WWW_CODING_DEFLATE); // <-- this just adds a
header

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

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

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

	return 0;
}

Received on Sunday, 23 April 2000 07:17:17 UTC