Subject: Re: [SWIPL] eof_action of current input stream

From: Jan Wielemaker <[email-masked]>
Date: Thu, 7 Jun 2001 22:25:54 +0200

> OK, another question relating to CGI scripting.
> 
> I've got SWI Prolog 4.05 running as a CGI script engine under Windows 2000's
> web server.  So far so good.
> 
> Now I'm trying to get input into it using the POST method (i.e., standard
> input).
> 
> Windows sends it a string that does not end with an end-of-line mark.

No, but as far as I know, CGI's are passed the environment variable
CONTENT_LENGTH, indicating the number of bytes you must read from the
standard input.

I've just extended set_stream/2 to allow controlling the buffering
of open streams, but it appears it would be a good idea to add some
more (binary/text mode, eof_action).

> And the eof_action for console input is eof_action(reset), so I can't detect
> the end-of-file condition -- instead, SWI Prolog waits forever for more
> characters to be typed.

You can still detect the end-of-file, as it returns -1.  

	--- Jan

P.s.	The libc package contains cgi.c.  In my internal release I've
	added this to the standard suite for Windows too (it was already
	in the Unix version).  If you want I can send you the DLL (it
	hasn't really been tested on Windows I'm afraid).