Getting both a chunk and HText callbacks

I am trying to use HTTee to get libwww to simultaneously from one
HTLoad to load the webpage into a chunk and also to call my HText
callbacks.  Here is the code I am using:

  HTRequest* request = HTRequest_new();
  HTNet_addAfter(&term_handler, 0, 0, HT_ALL, HT_FILTER_LAST);
  HTAlert_setInteractive(NO);
  HTHost_setEventTimeout(15000); // if can't load 15 secs, abort

  HTAnchor* anchor = HTAnchor_findAddress(url);
  HTRequest_setAnchor(request, anchor);

  HTChunk* chunkchunk = 0; 
//  HTRequest_setOutputFormat(request,WWW_SOURCE);
  HTStream* chunkstream = HTStreamToChunk(request,&chunkchunk,-1);

  HText_registerCDCallback(&RHText_new,&RHText_delete);
  HText_registerTextCallback(&add_text);
  HText_registerLinkCallback(&found_link);

  HTStream* target = HTTee(chunkstream, HTRequest_outputStream(request),0);

  HTRequest_setOutputStream(request, target);

  HTLoad(request, NO);

  HTEventList_newLoop();

  std::cerr << HTChunk_size(chunkchunk) << std::endl;
  char* strchunk = HTChunk_toCString(chunkchunk);
  std::cerr << strchunk << std::endl;


Depending on if the HTRequest_setOutputFormat line is commented or not I
either get the HText callbacks or I get the chunk, but I can't seem to
get both.

Any suggestions?

Joel
jdy@cs.brown.edu

Received on Friday, 25 May 2001 15:30:26 UTC