Article delegate-en/2995 of [1-5169] on the server localhost:119
  upper oldest olders older1 this newer1 newers latest
search
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
[Reference:<_A2990@delegate-en.ML_>]
Newsgroups: mail-lists.delegate-en

[DeleGate-En] Re: HTTP filtering and Windows
03 Jul 2005 08:17:32 GMT feedback@delegate.org (Yutaka Sato)
The DeleGate Project


Hi,

On 06/29/05(21:56) you "Lorant Horvath" <pvyfqbdyi-xgv6ctlt4ptr.ml@ml.delegate.org> wrote
in <_A2990@delegate-en.ML_>
 |I'm playing with DeleGate/9.0.2 on Windows 2000 trying to use CFI but it
 |does not seem to work, Delegate sets Content-Length: 0 and the http body
 |contains nothing. Could somebody give some help? Thanks in advance!
 |
 |Regards,
 |Lorant
 |
 |My cfi file contains:
 |#!cfi
 |Content-Type: text/html
 |Body-Filter: C:\cygwin\bin\sed.exe "s/script/deleted"

The command should be as "/script/d" to be acceptable by sed, if your
intention is to "delete lines including the string 'script'".
And you can use the internal builtin sed (-sed) for commands when the
matching pattern is simple like:

  Body-Filter: -sed "/to be deleted/d"


 |06/29 14:45:26.76 [8760] 0+0: systemFilter[with buffered input = 3418]:
 |C:\cygwin\bin\sed.exe "s/script/deleted"

I think you must have seen lines around here like

  "#### ERROR: select() appllied to non-SOCKET handle"

 |06/29 14:45:27.01 [8760] 0+0: simple_relay [27 -> 5] = (0 -> 0) / 0
 |(WIN) 45:27 [8760] wait(0) = ...

If so, it shows the reason of the error.
A filter program is connected to/from DeleGate with PIPE instead of socket,
since usual programs on Windows do not understand a socket as a
standard input/output.  But on Windows, pipe cannot be treated like socket
to be polled with select(X-<).  Here select() is used in simple_relay()
when an input to a filter is relayed by DeleGate, and when the input (body
of a HTTP message) is buffered in a stream buffer (prefetched together
on reading the HTTP header).  Thus the above problem occur.

I did the simplest solution for this problem like the patch enclosed, in
9.0.3-pre27.  I know it makes the CFIscript on Windows slower because it do
read() for each byte in a HTTP header, but anyway it makes CFI+external-filter
work.  The patched version is availabe at
<URL:ftp://ftp.delegate.org/pub/DeleGate/alpha/>


I will support ICAP in 9.0.X and extend or replace a part of CFI with it,
thus problems depending on local pipe() like this might be solved in the
new scheme.

Cheers,
Yutaka
--
  D G   Yutaka Sato <y.sato@delegate.org> http://delegate.org/y.sato/
 ( - )  National Institute of Advanced Industrial Science and Technology
_<   >_ 1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan
Do the more with the less -- B. Fuller

diff -cr delegate9.0.3-pre26/filters/cfi.c delegate9.0.3-pre27/filters/cfi.c
*** delegate9.0.3-pre26/filters/cfi.c	Fri Apr 22 05:49:57 2005
--- delegate9.0.3-pre27/filters/cfi.c	Sun Jul  3 10:14:18 2005
***************
*** 94,99 ****
--- 94,103 ----
  	/*
  	 *	HTTP
  	 */
+ 	if( isWindows() ){
+ 		/* suppress buffering HTTP body to let systemFilter() work... */
+ 		setbuf(in,NULL);
+ 	}
  	withhead = 1;
  	withbody = 1;
  	if( isresp ){


  admin search upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
@_@V