You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by Michael Smith <ms...@xn.com.au> on 2001/02/20 04:18:44 UTC

slide and proxies

Hi all,

I've run into a situation here where I need to go through a proxy (using
squid for testing, at the moment) to the webdav servlet.

The webdav client libraries have a bit of a problem here - no support
for proxies. I've hacked it in for now (it's pretty ugly. I'll send a
patch to anyone that's interested, but it isn't really release-quality
code, I just needed a solution immediately).

However, there's one more problem - squid complains (and returns a 411
error) if methods which aren't meant to have a Content-Length header
have one. For example, a get request should NOT have a content-length.
Right now, we send content-length whenever we can, though it'll often be
the default value (I haven't checked, but I imagine this is 0). So, we
need to suppress this on methods that don't need it. 

What's a neat solution to this? Should we: a) get each method to print
content-length if they need it, b) have a function in each method class
like this: boolean needContentLength(), and print based on that, or c)
(my current solution, for the moment, mostly because it's quick and easy
for a single special case) - just have it suppress the content-length
header if the method is a GET (that's the only one - so far - that's
caused a problem for me).

Michael

Re: slide and proxies

Posted by Remy Maucherat <re...@apache.org>.
> If you don't think this should be changed in slide (which is fair
> enough), that's fine with me - my proxy support is an ugly hack anyway,
> another ugly hack isn't a problem :)
> Hopefully I'll have time at some point (probably not soon, though) to
> clean up the proxy stuff so that it's a neat addition rather than the
> current hack, and then maybe we can return to this problem.

Too late, I already fixed it (at least I think so) :)
Since that means less bytes are sent, it can't be bad.

Remy


Re: slide and proxies

Posted by Michael Smith <ms...@xn.com.au>.
> Sure, here, fixing that is a no brainer (it also will save a few bytes in
> the request). However, in more complex cases, it's definitely conformance to
> the standard which matters.
> 
> If anyone could send a pointer to the chapter in the HTTP/1.1 spec which
> says that Content-Length: 0 is not allowed in a GET method, I would be
> interested.
> 

I had a quick look - there's nothing that says it isn't allowed. There's
one paragraph which weakly implies that it isn't allowed, but there are
other paragraphs that specifically state that a content-length of 0 IS
allowed. So I think that the client code is doing the right thing, in so
far as it isn't doing anything that ISN'T allowed, but it does seem to
cause problems with certain other programs.

If you don't think this should be changed in slide (which is fair
enough), that's fine with me - my proxy support is an ugly hack anyway,
another ugly hack isn't a problem :)
Hopefully I'll have time at some point (probably not soon, though) to
clean up the proxy stuff so that it's a neat addition rather than the
current hack, and then maybe we can return to this problem.

Michael

Re: slide and proxies

Posted by Remy Maucherat <re...@apache.org>.
> > > However, there's one more problem - squid complains (and returns a 411
> > > error) if methods which aren't meant to have a Content-Length header
> > > have one. For example, a get request should NOT have a content-length.
> > > Right now, we send content-length whenever we can, though it'll often
be
> > > the default value (I haven't checked, but I imagine this is 0). So, we
> > > need to suppress this on methods that don't need it.
> >
> > Where did you read that ?
> > As long as the content length value is accurate (ie, equals 0 when doing
a
> > GET), I fail to see why it would be forbidden (and couldn't find that in
the
> > HTTP/1.1 spec).
> > 411 means Length required, so it should be returned in the exact
opposite
> > case.
>
> I inferred it from a) various squid mailing list posts, b) the fact that
> squid gave a 411 when the client sent this content-length, and c) the
> fact that, when I supressed the content-length header for this case,
> squid started working.
>
> I'm not sure WHY squid requires this, and it might (though this isn't
> anything new - and squid is VERY widely used, so I suspect it's not a
> bug in squid) be a squid problem, but this fix does work.
>
> I would guess (but I haven't read the entirety of the HTTP rfcs
> sufficiently recently to remember) that when there isn't a body,
> content-length is not meant to be set. I'll check on this when I have
> time.

Sure, here, fixing that is a no brainer (it also will save a few bytes in
the request). However, in more complex cases, it's definitely conformance to
the standard which matters.

If anyone could send a pointer to the chapter in the HTTP/1.1 spec which
says that Content-Length: 0 is not allowed in a GET method, I would be
interested.

Remy


Re: slide and proxies

Posted by Michael Smith <ms...@xn.com.au>.
> > However, there's one more problem - squid complains (and returns a 411
> > error) if methods which aren't meant to have a Content-Length header
> > have one. For example, a get request should NOT have a content-length.
> > Right now, we send content-length whenever we can, though it'll often be
> > the default value (I haven't checked, but I imagine this is 0). So, we
> > need to suppress this on methods that don't need it.
> 
> Where did you read that ?
> As long as the content length value is accurate (ie, equals 0 when doing a
> GET), I fail to see why it would be forbidden (and couldn't find that in the
> HTTP/1.1 spec).
> 411 means Length required, so it should be returned in the exact opposite
> case.
> 

I inferred it from a) various squid mailing list posts, b) the fact that
squid gave a 411 when the client sent this content-length, and c) the
fact that, when I supressed the content-length header for this case,
squid started working.

I'm not sure WHY squid requires this, and it might (though this isn't
anything new - and squid is VERY widely used, so I suspect it's not a
bug in squid) be a squid problem, but this fix does work.

I would guess (but I haven't read the entirety of the HTTP rfcs
sufficiently recently to remember) that when there isn't a body,
content-length is not meant to be set. I'll check on this when I have
time.

Michael

Re: slide and proxies

Posted by Remy Maucherat <re...@apache.org>.
> Hi all,
>
> I've run into a situation here where I need to go through a proxy (using
> squid for testing, at the moment) to the webdav servlet.
>
> The webdav client libraries have a bit of a problem here - no support
> for proxies. I've hacked it in for now (it's pretty ugly. I'll send a
> patch to anyone that's interested, but it isn't really release-quality
> code, I just needed a solution immediately).
>
> However, there's one more problem - squid complains (and returns a 411
> error) if methods which aren't meant to have a Content-Length header
> have one. For example, a get request should NOT have a content-length.
> Right now, we send content-length whenever we can, though it'll often be
> the default value (I haven't checked, but I imagine this is 0). So, we
> need to suppress this on methods that don't need it.

Where did you read that ?
As long as the content length value is accurate (ie, equals 0 when doing a
GET), I fail to see why it would be forbidden (and couldn't find that in the
HTTP/1.1 spec).
411 means Length required, so it should be returned in the exact opposite
case.

> What's a neat solution to this? Should we: a) get each method to print
> content-length if they need it, b) have a function in each method class
> like this: boolean needContentLength(), and print based on that, or c)
> (my current solution, for the moment, mostly because it's quick and easy
> for a single special case) - just have it suppress the content-length
> header if the method is a GET (that's the only one - so far - that's
> caused a problem for me).

Remy