- From: Cal Caldwell <Caldwell@kfalls.net>
- Date: Thu, 16 Mar 2000 17:41:42 -0800
- To: <www-lib@w3.org>
- Message-ID: <072f01bf8fb1$f2ade810$05640a0a@kfallsdev>
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; HTEventInit(); 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); HTPrint_setCallback(printer); HTTrace_setCallback(tracer); /* Sets up headers */ HR(p_phh_headers->get_Headers(&lng_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)); } HR(p_phm_message->GetMessage(&str_message)); 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) HTEventList_newLoop(); 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) { USES_CONVERSION; 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)); fclose(f); HTRequest_delete(request); return 1; }
Received on Thursday, 16 March 2000 20:36:37 UTC