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

Using deflate encoding with libwww

From: Yaniv Ben-Yosef <yaniv@contact.com>
Date: Sun, 23 Apr 2000 14:15:40 +0200
To: <www-lib@w3.org>
Message-ID: <000601bfad1d$a451e2f0$1044a8c0@YANIVDESKTOP>
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

	** 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

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