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

Please Help on Synchronous Post...

From: Cal Caldwell <Caldwell@kfalls.net>
Date: Thu, 16 Mar 2000 17:41:42 -0800
Message-ID: <072f01bf8fb1$f2ade810$05640a0a@kfallsdev>
To: <www-lib@w3.org>
Hi All:
We are trying to do a synchronous Post which, by nature, should block execution and then continue once the post is completed.  I have included some code below that calls HTPostAbsolute followed by HTEventList_newLoop(). The terminate handler fires but the HTEventList_newLoop() function never RETURNS.  Nothing following the HTEventList_newLoop() call ever executes.  However, control is given back to the test application.  In other words, I press a button on a simple GUI to perform a Post and I can press the button again before the Post is completed. If I wait long enough, the POST will result in a successful Response.  This leads me to believe the Post is working correctly, it just doesn't seem to be synchronous.... 

I have scoured the archives and found some discussion on this topic but not any sample code.  Any help would be greatly appreciated...

 HTRequest* phtr_request;
 HTParentAnchor * phpa_dsource;
 long lng_loop, lng_headers;
 CComBSTR str_headerName, str_headerValue, str_message; --you linux guys will love this!!:)
 BOOL bln_result;

 phtr_request = HTRequest_new(); 
 phpa_dsource = HTTmpAnchor(NULL);

    HTRequest_setOutputFormat(phtr_request, WWW_SOURCE);
    HTRequest_setOutputStream(phtr_request, HTStreamToChunk(phtr_request, &g_phc_responseData, -1));
    HTRequest_setPreemptive(phtr_request, YES);

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

/* Sets up headers */ 
 for (lng_loop = 0; lng_loop < lng_headers; lng_loop++)
  HR(p_phh_headers->GetHeader(lng_loop, &str_headerName, &str_headerValue));

     bln_result = HTRequest_addExtraHeader(phtr_request, W2A(str_headerName), W2A(str_headerValue));
 HTAnchor_setDocument(phpa_dsource, W2A(str_message));
 HTAnchor_setLength(phpa_dsource, str_message.Length());
  bln_result = HTPostAbsolute(phpa_dsource, W2A(p_str_address), phtr_request);
 if (bln_result == YES) 

 HTEventTerminate();  /* NEVER GETS CALLED */

 return S_OK;

/*  Here is the terminate handler */
static int CHttpPost::terminate_handler (HTRequest * request, HTResponse * response, void * param, int status) 
 CComBSTR str_response;
 CHttpPost* php_this;
 php_this = (CHttpPost*)param;

 str_response = HTChunk_data(php_this->g_phc_responseData);

 FILE* f= fopen("C:\\log.txt", "a+");
 fprintf(f, "%s\n", W2A(str_response));

 return 1;
Received on Thursday, 16 March 2000 20:36:37 UTC

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