BBlack has submitted this change and it was merged.

Change subject: [HAT] text-frontend VCL: set Content-Type if not set
......................................................................


[HAT] text-frontend VCL: set Content-Type if not set

Our Apache configuration on the application servers includes "DefaultType
application/octet-stream", which tells Apache to set a Content-Type header with
that value if a Content-Type header was not already present on the response.
Apache 2.4 drops support for this option on the ground that the correct
behavior (as mandated by RFC 1945 and 2616) is to not set a Content-Type header
if the content-type is not known.

We're fine with this in principle, but there's a bigger sense of "if it ain't 
broken".
It's very difficult to anticipate the impact of removing this behavior, because
there is no straightforward way to distinguish organic application/octet-stream
headers from default-set ones, and thus no straightforward way to know in which
cases (if any) we rely on this behavior.

So, do it Varnish instead. It's trivial to do in VCL, and it comes with the
added benefit of being easier to instrument if we decide we want to analyze
this in the future.

* https://issues.apache.org/bugzilla/show_bug.cgi?id=13986
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=440058

RT: 7700
Change-Id: I2574db03706e2bd5ba4f4903afd8f5a9fd83bb2a
---
M modules/varnish/templates/vcl/wikimedia.vcl.erb
1 file changed, 14 insertions(+), 0 deletions(-)

Approvals:
  BBlack: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/varnish/templates/vcl/wikimedia.vcl.erb 
b/modules/varnish/templates/vcl/wikimedia.vcl.erb
index 3481627..d1861a9 100644
--- a/modules/varnish/templates/vcl/wikimedia.vcl.erb
+++ b/modules/varnish/templates/vcl/wikimedia.vcl.erb
@@ -370,6 +370,20 @@
                }
        }
 
+       /* If no Content-Type header is present in the response, set a default
+        * Content-Type header with a value of "application/octet-stream".
+        * This was formerly handled by Apache via the DefaultType directive
+        * but had to be moved to the Varnish layer due to Apache 2.4 dropping
+        * support for DefaultType. (RT #7700)
+        */
+       if ((resp.status == 200 || resp.status == 201 || resp.status == 202 || 
resp.status == 203 || resp.status == 206) && !resp.http.Content-Type && 
resp.http.Server ~ "Apache") {
+               set resp.http.Content-Type = "application/octet-stream";
+
+               /* Log to syslog so we can determine how prevalent such 
responses are.
+                * This is temporary. -- OL, 23-Jun-2014 */
+               std.syslog(9, "DefaultType: " + req.url);
+       }
+
        /* Function vcl_deliver in <%= vcl %>.inc.vcl will be appended here */
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/141086
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2574db03706e2bd5ba4f4903afd8f5a9fd83bb2a
Gerrit-PatchSet: 4
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Mark Bergsma <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to