[Web-SIG] Request and Response objects

David Fraser davidf at sjsoft.com
Wed Oct 29 23:31:08 EST 2003

Gregory (Grisha) Trubetskoy wrote:

>Let me argue the single request point with some specifics.
>IMO dual objects create a semantics mess, here is a couple of examples:
>o The point that I already brought up that reading from one object and
>writing to another is unintuitive and misleading.
>o Where does the connection information such as remote host, the raw
>socket, etc information belong, request or response?
>o Mod_python (or httpd rather) allows for cleanups to be registered, to
>run after the request is finished being processed. Again - where would a
>clean up fit in, at the end of a _request_ or at the end of a _response_?
>(and when _does_ a request really end?)
>o What about server information (document root, etc)?
>o If there exists such a thing as a subrequest or internal redirect, then
>in httpd's single object framework you can access the previous and next
>request objects via req.prev or req.next. With two objects, it would be
>something like response.subreq and response.subreq.resp, and to dig one
>level deeper (req.next.next in single object model), it would be
>Or if I am within a subrequest, how can I get at the parent (req.prev)?
> - you see my point, I hope.
>6. When processing is aborted, which could happen while the request is
>being read or while the response is being written - the logic should not
>be duplicated in two different objects.
>These are a few problems that I can think of with the dual object model,
>yet so far I haven't seen anything seriously convincing in advocacy of the
>dual object model :-)
Great explanation, Grisha.
A lot of the arguments for the dual object model are about what you can 
do with a separate object.
But these seem to me to miss the point .... you can create your own 
"response"-type class that holds the *value* of a response, and as many 
instances of it per request as you want to. But the actual Web API 
response object is for *writing* the response back to the client. You 
can only write one response back per request, so it makes sense for them 
to be the same object.
(The only extension would be to filter what is being written, but this 
is a separate issue).


More information about the Web-SIG mailing list