Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/141086

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.

Change-Id: I2574db03706e2bd5ba4f4903afd8f5a9fd83bb2a
RT: 7700
---
M templates/varnish/text-frontend.inc.vcl.erb
1 file changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/86/141086/1

diff --git a/templates/varnish/text-frontend.inc.vcl.erb 
b/templates/varnish/text-frontend.inc.vcl.erb
index 7218468..66c9df3 100644
--- a/templates/varnish/text-frontend.inc.vcl.erb
+++ b/templates/varnish/text-frontend.inc.vcl.erb
@@ -129,6 +129,17 @@
                && req.url !~ "(?i)bcache=1") {
                set resp.http.Cache-Control = "private, s-maxage=0, max-age=0, 
must-revalidate";
        }
+
+       /* 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.http.Content-Type) {
+               set resp.http.Content-Type = "application/octet-stream";
+       }
+
 <% if cluster_options.fetch( "enable_geoiplookup", false ) -%>
        /* Perform GeoIP look-up and send the result as a session cookie */
        if (req.http.Orig-Cookie !~ "(^|;\s*)GeoIP=[^;]"

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2574db03706e2bd5ba4f4903afd8f5a9fd83bb2a
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>

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

Reply via email to