Subject: Proxies, how to determine response body length

From: Jan Novy <[email-masked]>
Date: Mon, 12 Jul 2004 12:11:36 +0200 (CEST)

After reading RFC2616 I'am not sure how HTTP1.1 proxy server can 
determine response body length on client-proxy side connection 
when this length was determined by the server closing the connection
on proxy-originserver side connection. I'am not sure that proxy server
can determine it by closing the connection, because for some 
particular client-proxy connection proxy can have many persistent 
connections (to different origin servers) opened so determining 
response body length by closing client-proxy connection would cause 
loss of remaining proxy-originserver persistent connections I think. 
Thanks for answers j.n. 
____________________________________________________________
Dřív zničíš sám sebe! SIEMENS M65 již od 4977 Kč.
http://ad.seznam.cz/clickthru?spotId=75824

---

From: Jamie Lokier <[email-masked]>
Date: Mon, 12 Jul 2004 12:31:54 +0100

Jan Novy wrote:
> on proxy-originserver side connection.

That's correct, it can't.  The proxy does not know the body length
until the end of the body.  It is the same if the body is transmitted
with chunked encoding.

> I'am not sure that proxy server can determine it by closing the
> connection, because for some particular client-proxy connection
> proxy can have many persistent connections (to different origin
> servers) opened so determining response body length by closing
> client-proxy connection would cause loss of remaining
> proxy-originserver persistent connections I think.

If there are many persistent client-proxy connections open, that's
irrelevant.  A message is terminated by closing only the connection
for that message: the other client-proxy connections aren't affected.

That's what you need to do if the client speaks only HTTP/1.0.
Alternatively you can buffer the message until you know the length,
which is good idea for short messages where the whole message arrives
in a very short time.

If the client speaks HTTP/1.1, then you can send the body using
chunked encoding over the client-proxy connection, at the same time as
receiving it over the proxy-server (or proxy-proxy) connection.

-- Jamie

---

From: Robert Olofsson <[email-masked]>
Date: Mon, 12 Jul 2004 19:10:49 +0200

Jan Novy wrote:

>closing client-proxy connection would cause 
RFC2616:8.1.2.2  second paragraph may be good to read again
"...Clients MUST also be prepared to resend their requests if the server
closes the connection before sending all of the corresponding responses."

So if you have tried to pipeline and have requests in the pipe and the
pipe is closed, you retry with a new connection. This applies to both the
client and the proxy (when the proxy is acting client to a origin server).

If the proxy has outstanding proxy-server requests when it closes a
proxy-client connection it may _perhaps_ want to shut down those requests
as well. If the proxy is a caching proxy it could also just cache the 
resources
and hope that the client will want the resources soon.

In short: it is easy to act the server side of a pipeline, since you 
then control
the closing. It is also hard to act the client side, since you then have 
to handle
retries for requests that have the pipeline blown up in the middle.

I think that my proxy(rabbit) handles pipelining quite ok in both 
directions,
but the pipelining proxy-server is a bit messy, feel free to check it 
out. Rabbit
is written in java and uses a BSD-style licence so it ought to be ok for 
you to
read or use it. You find it at http://www.khelekore.org/rabbit/

/robo