Streaming to standard output?

Hi,

the following is my first program using wwwlib:
=== cut ===
#include <stdio.h>

extern "C"
{
#include "wwwconf.h"
#include "WWWLib.h"
#include "HTTP.h"
#include "HTProfil.h"
#include "HTFWrite.h"
};

//#define BROKEN

int terminate_handler(HTRequest *request,
    HTResponse *response,
    void *param,
    int status)
{
    HTRequest_delete(request);
    HTProfile_delete();
    exit(status ? status : 0);
}

int main(int argc, char **argv)
{
    HTProfile_newRobot("test-spider", "0.01");
    /* Add our own filter to terminate the application */
    HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL,
HT_FILTER_LAST);

    HTRequest *request = HTRequest_new();

#ifdef BROKEN
    HTStream *output = HTFWriter_new(request,
	stdout,
	NO);
    HTLoadToStream(argc >= 2 ? argv[1] : "http://localhost/",
	output,
	request);
#else
    HTLoadToFile(argc >= 2 ? argv[1] : "http://localhost/",
	request,
	"out.txt");
#endif

    HTEventList_loop(request);

    // shouldn't get here
    return -1;
}
=== end cut ===
It works as expected (finally :-) ): GETs a page
and saves it into a local file. But when I
#define BROKEN, it doesn't work - i. e. it compiles
and runs, but produces no output. What am I doing
wrong? In case it matters, I'm running RedHat Linux
and egcs 2.91.60 (the program is compiled as C++).
I checked out the latest version of the library
(and tested my code with it) before posting.

	Bye
		Vasek

Received on Friday, 12 February 1999 15:15:39 UTC