Bad idea or not (I don't think it will be fast and there are some problems with some of the ideas you want to pull off, imho) I certainly believe that reinventing the wheel can be a healthy exercise.

That having been said, most of what you want to accomplish here requires a single lon-living process. php only sends headers once per request/c[lg]i invocations , so this won't do what you're hoping for.

Seems to me that you would want to do something like this, using the cli:

startup
listen
while 1:
accept
read request
set buffering true
use a userspace function to generate headers
use a userspace function to generate body
capture buffer
close buffer
send captured buffer over socket


You should be able to modify the sapi functions to buffer headers as well, but a) then your server is written in C, not in php and b) I think this isn't useful for too many applications.

George


On Sunday, November 24, 2002, at 06:06 PM, David Brown wrote:

Hi George:

It's something that's probably better solved in user-space, but I
figured I'd poke around anyway. :)

I'm attempting to write a little prefork HTTP server entirely in PHP.
The script instansiates an 'application class', which is persistent
across requests. Output of the application is captured with an ob_*
callback function, and then stuffed down a socket. I'm hoping for free
in-memory opcode caching and database connection persistence (by virtue
of recycling the same interpreter across multiple requests), and
possibly the elimination of a lot of application-specific startup time.

Of course, this whole thing could very well just be a bad idea. :)

Anyway, headers aren't currently included in the buffered output, which
causes the header() function to print to stdout, effectively doing
nothing. I could just wrap header() with a user-space function, but that
would prevent a lot of scripts from running as-is.

Bad idea? Maybe. There's also the matter of getting it to parse
POST/GET without completely reinventing the wheel...

- Dave


On Sun, Nov 24, 2002 at 05:57:33PM -0500, George Schlossnagle wrote:
| What are you trying to accomplish?
|
|
| On Sunday, November 24, 2002, at 05:40 PM, David Brown wrote:
|
| >Hi:
| >
| >Architecturally speaking, is there any simple way to modify an sapi
| >backend to return HTTP headers through the output buffering mechanism?
| >
| >As far as I can tell, headers are managed seperately by main/output.c,
| >with php_ub_body_write_no_header being substituted in once the HTTP
| >headers are sent.
| >
| >Pointers to anything would be greatly appreciated.
| >
| >TIA,
| >- Dave
| >
| >
| >--
| >PHP Development Mailing List <http://www.php.net/>
| >To unsubscribe, visit: http://www.php.net/unsub.php
| >
|
|

--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to