Problems with data POST

Hello!

I'm posting some data (in message body) to the server, that supports
keep-alive. The posting works fine, server replies immidiately. But I
have some strange timeout (about 10 seconds) from last bytes read to
call of terminate_handler. The status returned to the handler is -1, but
the result chunk is correct. What's wrong? Maybe I need to set some
timeout or something?

I have the following code to get data from server:
===========
PRIVATE int terminate_handler (HTRequest * request, HTResponse *
response,
                               void * param, int status)
{
	HTEventList_stopLoop ();

	return 0;
}


PUBLIC HTChunk * HTPostAnchorToChunk(HTParentAnchor *  source, HTAnchor*
destination, HTRequest* request)
{
	if (source && destination && request) {
		HTChunk * chunk = NULL;
		HTStream * target = HTStreamToChunk(request, &chunk,
-1);
		HTRequest_setOutputStream(request, target);
		if (HTPostAnchor(source, destination, request) != NULL)
			return chunk;
		else {
			HTChunk_delete(chunk);
			return NULL;
		}
	}
	return NULL;
}

int main (int argc, char ** argv)
{
	HTRequest * request = NULL;
	HTParentAnchor * src = NULL;
	HTAnchor * dst = NULL;
	HTAnchor * anchor = NULL;
    char * dst_str = NULL;
    char * xml_data = NULL;
    BOOL status = NO;

	HTProfile_newNoCacheClient("libwww-POST", "1.0");

    //HTSetTraceMessageMask("sop");

    HTPrint_setCallback(printer);
    HTTrace_setCallback(tracer);

	HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL,
HT_FILTER_LAST);

	if (argc >= 2) {
		dst_str = argv[1];
	} else {
        HTPrint("Type the URI of the destination you want to POST.\n");
        HTPrint("\t%s <destination>\n", argv[0]);
        HTPrint("For example, %s http://myserver/destination.html\n",
argv[0]);
		return -1;
    }

    if (dst_str && *dst_str) {
		char message[10000];

		long readBytes;
		FILE* f = fopen("request", "rb");
		if (!f) {
			printf("Error opening request file!\n");
			return 0;
		}
		readBytes = fread(message, 1, 10000, f);
		if (readBytes == 10000) {
			HTPrint("Too large file\n");
			return -1;
		}
		fclose(f);
		
		char * cwd = HTGetCurrentDirectoryURL();
		request = HTRequest_new();
		HTRequest_setOutputFormat(request, WWW_RAW);

		anchor = HTAnchor_findAddress(dst_str);

		src = HTTmpAnchor(NULL);
		HTAnchor_setDocument(src, message);
		HTAnchor_setFormat(src, HTAtom_for("text/xml"));
		HTAnchor_setCharset(src, HTAtom_for("UTF-8"));
		HTAnchor_setLength(src, readBytes);

		result = HTPostAnchorToChunk(src, anchor, request);
			
		if (!result)
		{
			printf ("NULL Response!!\n");
		}
		else
		{
			HTEventList_loop(request);

			HTPrint("---Printing response---->%s",
HTChunk_data(result));
			HTChunk_delete(result);
		}

		HTRequest_delete(request);

		HTProfile_delete();
	}
	return 0;
}
===========

I'm posting some data to the server. The log on the screen looks like
following:
===========
Looking up jurgen
Looking up jurgen
Contacting jurgen
Writing 1Kbytes
Writing 1Kbytes
Reading...
Reading...
Reading...
Reading...
===========


Best regards,
Alik.

Received on Tuesday, 22 January 2002 13:36:26 UTC