Skip to content
Prev Previous commit
Next Next commit
Parsoid: Set content-language and vary if they are missing
This is a temporary measure until Parsoid/PHP has the capability to do
language conversion at which point it will start emitting them.

Bug: T236382
Bug: T221174
Bug: T230791
  • Loading branch information
Marko Obrovac committed Oct 24, 2019
commit ccdf409490c50832dd4b34518e983cab14ff319b
12 changes: 12 additions & 0 deletions lib/parsoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,22 @@ class ParsoidService {
})
.then((res) => {
const etag = res.headers.etag;
// TEMP TEMP TEMP: T236382 / T221174 shim content-language and vary if missing
const cl = res.headers['content-language'];
// END TEMP 1
// Chop off the correct format to return.
res = Object.assign({ status: res.status }, res.body[format]);
res.headers = res.headers || {};
res.headers.etag = etag;
// TEMP TEMP TEMP: T236382 / T221174 shim content-language and vary if missing
if (!res.headers['content-language'] || !res.headers.vary) {
hyper.logger.log('warn/parsoid/headers', {
msg: 'Missing Content-Language or Vary header in pb.body.html.headers'
});
}
res.headers['content-language'] = res.headers['content-language'] || cl || 'en';
res.headers.vary = res.headers.vary || 'Accept';
// END TEMP 2
mwUtil.normalizeContentType(res);
if (req.query.stash) {
// The stash is used by clients that want further support
Expand Down