On Thu, May 09, 2002 at 05:18:42PM -0700, Aaron Bannert wrote: >... > The basic pattern for any input filter (which is pull-based at the moment > in Apache) would be the following: > > 1. retrieve next "abstract data unit" > 2. inspect "abstract data unit", can we operate on it? > 3. if yes, operate_on(unit) and pass the result to the next filter. > 4. if no, pass the current unit to the next filter. > 5. go to #1 > > In this model, the operate_on() behavior has been separated from the > mechanics of passing data around. I believe this would improve filter
That's fine, as long as you ensure that the retrieval can be bounded. When the HTTP processor realizes that it can only read 100 more bytes from the next-filter, then you're outside of "abstract data unit" and into "concrete 100 bytes." Due to the presence of the Upgrade: header, an HTTP processing filter must always be per-request, and must never read past the end of its request. That enforces a number of limitations on your design. [ unless you go for "pushback", which I believe is a poor design. ] What would be neat is to have a connection-level filter that does HTTP processing, but can be signalled to morph itself into a simple buffer. For example, let's say that filter pulls 10k from next-filter ("pull" here, remember). It parses up the data into some headers and a 500 byte body. It has 9k leftover, which it holds to the side. Now, the request processor sees an "Upgrade" and switches protocols to something else entirely. The connection filter gets demoted to a simple buffer, returning the 9k without processing. When the buffer is empty, it removes itself from the filter stack. The implication here is that filters need to register with particular hooks in the server. In particular, with a hook to state that a protocol change has occurred on <this> connection (also implying an input and an output filter stack). The protocol-related filters in the stack can then take appropriate action (in the above example, to disable HTTP processing and just be a buffer). Other subsystems may have also registered with the hook and will *install* new protocol handler filters. You could even use this protocol-change hook to set up the initial HTTP processing filters. Go from "null" protocol to "http", and that installs your chunking, http processing, etc. It could even be the mechanism which tells the MPM to call ap_run_request (??) (the app-level thing which starts sucking input from the filter stack and processing it). Cheers, -g -- Greg Stein, http://www.lyra.org/