You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Joe Orton <jo...@redhat.com> on 2004/11/22 12:30:00 UTC

[PATCH] another mod_deflate vs 304 response case

There's another mod_deflate vs 304 response problem which is being
triggered by ViewCVS on svn.apache.org: when a CGI script gives a
"Status: 304" response the brigade contains a CGI bucket then the EOS,
so fails the "if this brigade begins with EOS do nothing" test added for
the proxied-304 case.

I wonder if the simplest fix is to just explicitly test for a 304/204
response instead.  Were there any more EOS-only brigade cases this won't
catch?

Index: modules/filters/mod_deflate.c
===================================================================
--- modules/filters/mod_deflate.c	(revision 106098)
+++ modules/filters/mod_deflate.c	(working copy)
@@ -354,7 +354,7 @@
          * proxy may pass through an empty response for a 304 too.
          * So we just need to fix up the headers as if we had a body.
          */
-        if (APR_BUCKET_IS_EOS(APR_BRIGADE_FIRST(bb))) {
+        if (r->status == HTTP_NOT_MODIFIED || r->status == HTTP_NO_CONTENT) {
             if (!encoding || !strcasecmp(encoding, "identity")) {
                 apr_table_set(r->headers_out, "Content-Encoding", "gzip");
             }

Re: [PATCH] another mod_deflate vs 304 response case

Posted by Cliff Woolley <jw...@virginia.edu>.
On Mon, 22 Nov 2004, Roy T. Fielding wrote:

> Quoting "William A. Rowe, Jr." <wr...@rowe-clan.net>:
>
> > >Okay, but why the next three lines?  Why would Content-Encoding: gzip
> > >*ever* be set on a 304?
>
> Because Content-* header fields in a 304 response describe
> what the response entity would contain if it were a 200 response.
> Therefore, the header field must be the same as it would be for
> a 200.  The body must be dropped by the HTTP filter.

Aha.  Yeah okay that makes total sense.  Thanks Roy.  :)

Re: [PATCH] another mod_deflate vs 304 response case

Posted by Joe Orton <jo...@redhat.com>.
On Tue, Nov 23, 2004 at 07:51:19PM +0000, Joe Orton wrote:
> On Mon, Nov 22, 2004 at 11:40:29PM -0800, Roy T. Fielding wrote:
> > Quoting "William A. Rowe, Jr." <wr...@rowe-clan.net>:
> > 
> > > >Okay, but why the next three lines?  Why would Content-Encoding: gzip
> > > >*ever* be set on a 304?
> > 
> > Because Content-* header fields in a 304 response describe
> > what the response entity would contain if it were a 200 response.
> > Therefore, the header field must be the same as it would be for
> > a 200.  The body must be dropped by the HTTP filter.
> 
> That seems at odds with what 304 states unless I'm missing something?
			      ^^^^ RFC2616

Re: [PATCH] another mod_deflate vs 304 response case

Posted by Joe Orton <jo...@redhat.com>.
On Mon, Nov 22, 2004 at 11:40:29PM -0800, Roy T. Fielding wrote:
> Quoting "William A. Rowe, Jr." <wr...@rowe-clan.net>:
> 
> > >Okay, but why the next three lines?  Why would Content-Encoding: gzip
> > >*ever* be set on a 304?
> 
> Because Content-* header fields in a 304 response describe
> what the response entity would contain if it were a 200 response.
> Therefore, the header field must be the same as it would be for
> a 200.  The body must be dropped by the HTTP filter.

That seems at odds with what 304 states unless I'm missing something?

10.3.5 says you MUST NOT or SHOULD NOT send any entity headers with a
304 except those explictly mentioned, which means the only Content-*
header which should be sent is a Content-Length.  I could interpret that
paragraph to be talking only about caches, but this is exactly the logic
which 1.3 and 2.0 implement as special case for a 304 response.

joe

Re: [PATCH] another mod_deflate vs 304 response case

Posted by "Roy T. Fielding" <fi...@gbiv.com>.
Quoting "William A. Rowe, Jr." <wr...@rowe-clan.net>:

> >Okay, but why the next three lines?  Why would Content-Encoding: gzip
> >*ever* be set on a 304?

Because Content-* header fields in a 304 response describe
what the response entity would contain if it were a 200 response.
Therefore, the header field must be the same as it would be for
a 200.  The body must be dropped by the HTTP filter.

....Roy

Re: [PATCH] another mod_deflate vs 304 response case

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 10:26 AM 11/22/2004, Cliff Woolley wrote:
>On Mon, 22 Nov 2004, Joe Orton wrote:
>
>> There's another mod_deflate vs 304 response problem which is being
>> triggered by ViewCVS on svn.apache.org: when a CGI script gives a
>> "Status: 304" response the brigade contains a CGI bucket then the EOS,
>> so fails the "if this brigade begins with EOS do nothing" test added for
>> the proxied-304 case.
>
>Okay, but why the next three lines?  Why would Content-Encoding: gzip
>*ever* be set on a 304?

Let me expand on this question...

... we've all seen broken browsers.  Why attempt to gzip non-2xx
responses at all?  I'd prefer (at least on servers with modest error
message responses) to ensure the user can *read* any error response,
in spite of any broken browser behavior w.r.t. deflate.

It seems like a flag (even default) dropping gzip from non-2xx class
responses could be a very useful thing.  At least, if the browser
results are a mess, it's due to a good response.

Thoughts?

Bill



Re: [PATCH] another mod_deflate vs 304 response case

Posted by Cliff Woolley <jw...@virginia.edu>.
On Mon, 22 Nov 2004, Joe Orton wrote:

> > Okay, but why the next three lines?  Why would Content-Encoding: gzip
> > *ever* be set on a 304?
>
> I was wondering that too.  The answer to the latter is that it *won't*
> be sent for a 304 because the http_header filter knows better than that.

Well, okay.  But should we even set it in that case?  Is it correct to
send it in the 204 case?

Re: [PATCH] another mod_deflate vs 304 response case

Posted by Joe Orton <jo...@redhat.com>.
On Mon, Nov 22, 2004 at 11:26:18AM -0500, Cliff Woolley wrote:
> On Mon, 22 Nov 2004, Joe Orton wrote:
> 
> > There's another mod_deflate vs 304 response problem which is being
> > triggered by ViewCVS on svn.apache.org: when a CGI script gives a
> > "Status: 304" response the brigade contains a CGI bucket then the EOS,
> > so fails the "if this brigade begins with EOS do nothing" test added for
> > the proxied-304 case.
> >
> > I wonder if the simplest fix is to just explicitly test for a 304/204
> > response instead.  Were there any more EOS-only brigade cases this won't
> > catch?
> 
> Okay, but why the next three lines?  Why would Content-Encoding: gzip
> *ever* be set on a 304?

I was wondering that too.  The answer to the latter is that it *won't*
be sent for a 304 because the http_header filter knows better than that.

joe


Re: [PATCH] another mod_deflate vs 304 response case

Posted by Graham Leggett <mi...@sharp.fm>.
Cliff Woolley wrote:

> Okay, but why the next three lines?  Why would Content-Encoding: gzip
> *ever* be set on a 304?

In theory the 304 might be in response to a freshness check on the 
particular variant that was compressed. (Assuming I am not mixing up my 
content and transfer encodings).

Regards,
Graham
--

Re: [PATCH] another mod_deflate vs 304 response case

Posted by Cliff Woolley <jw...@virginia.edu>.
On Mon, 22 Nov 2004, Joe Orton wrote:

> There's another mod_deflate vs 304 response problem which is being
> triggered by ViewCVS on svn.apache.org: when a CGI script gives a
> "Status: 304" response the brigade contains a CGI bucket then the EOS,
> so fails the "if this brigade begins with EOS do nothing" test added for
> the proxied-304 case.
>
> I wonder if the simplest fix is to just explicitly test for a 304/204
> response instead.  Were there any more EOS-only brigade cases this won't
> catch?

Okay, but why the next three lines?  Why would Content-Encoding: gzip
*ever* be set on a 304?