File size: 524 Bytes
befd7da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';

function copyProxyResHeadersToUserRes(container) {
  return new Promise(function (resolve) {
    var res = container.user.res;
    var rsp = container.proxy.res;

    if (!res.headersSent) {
      res.status(rsp.statusCode);
      Object.keys(rsp.headers)
        .filter(function (item) { return item !== 'transfer-encoding'; })
        .forEach(function (item) {
          res.set(item, rsp.headers[item]);
        });
    }

    resolve(container);
  });
}

module.exports = copyProxyResHeadersToUserRes;