W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2000

After filter not run after successful Put

From: Jerker Hammarberg <jerha202@student.liu.se>
Date: Thu, 3 Aug 2000 08:03:35 -0400 (EDT)
Message-ID: <005601bffd42$c54c6410$1401a8c0@mediate>
To: <www-lib@w3.org>
Hi! I have a problem, please help!

I'm trying to do a simple put of data (from memory) to a URL. The problem
is that I (apparently) have to enter the event loop for having the request
processed, but I can't terminate the event loop in the case when the Put
was successful. I try to terminate the loop with an After filter, but it seems
that this filter is never executed after successful Put. On the other hand,
when the Put fails, the filter is executed.

Most of all I would like to never enter the loop - just call a procedure that
simply does the job. Is there one? If not, can someone give me a guess
about what can be wrong? The essential code pieces are given below.

Thanks in advance,
Jerker

int terminator( HTRequest* request, HTResponse* response, void* param, int status ) 
{
  std::cerr << "Now in terminator" << std::endl;
  HTNet_deleteAfter( terminator );
  HTRequest_delete( request );
  HTEventList_stopLoop();

  return HT_OK;
}

int main( void )
{
  // The following 10 lines are placed in another procedure in the real application
  HTList* encodings = HTList_new();
  HTLibInit( "PutApp", "1.0" );
  HTEventInit();
  HTTransportInit();
  HTProtocolInit();
  HTNetInit();
  HTAAInit();
  HTTransferEncoderInit( encodings );
  HTFormat_setTransferCoding( encodings );
  HTMIMEInit();

  HTRequest* request = HTRequest_new();
  HTAnchor* dst = HTAnchor_findAddress( /* URL */ );
  HTParentAnchor* src = HTTmpAnchor( NULL );

  HTAnchor_setDocument( src, /* Data block pointer */ );
  HTAnchor_setFormat( src, WWW_PLAINTEXT );
  HTAnchor_setLength( src, /* Data block size */ );
  HTNet_addAfter( terminator, NULL, NULL, HT_ALL, HT_FILTER_LAST );

  bool status = HTPutAnchor( src, dst, request );
  if( status )
  {
    HTEventList_loop(request);
  }

  // The following 3 lines are placed in another procedure in the real application
  HTFormat_deleteAll();
  HTEventTerminate();
  HTLibTerminate();
}
Received on Thursday, 3 August 2000 08:06:21 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:37 GMT