diff options
Diffstat (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/connection/response.js')
-rw-r--r-- | data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/connection/response.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/connection/response.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/connection/response.js new file mode 100644 index 0000000..c0ed791 --- /dev/null +++ b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/connection/response.js @@ -0,0 +1,44 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +'use strict'; + +const { Ci } = require('chrome'); +const { List, addListItem, removeListItem } = require('sdk/util/list'); +const { ns } = require('sdk/core/namespace'); +const { Class } = require('sdk/core/heritage'); + +const events = require('./events'); + +const RESPONSE_RULES = List(); + +const requestNS = ns(); + +function onResponse(evt) { + for each (let rule in RESPONSE_RULES) { + applyResponseHeaders(rule, evt) + } +} +events.on('examine-response', onResponse); + +const ResponseRule = Class({ + initialize: function(details) { + requestNS(this).details = details; + addListItem(RESPONSE_RULES, this); + }, + destroy: function() { + removeListItem(RESPONSE_RULES, this); + } +}); +exports.ResponseRule = ResponseRule; + +function applyResponseHeaders(rule, evt) { + let channel = evt.subject.QueryInterface(Ci.nsIHttpChannel); + let requestURL = channel.URI.spec + + let details = requestNS(rule).details; + let { headers: rules } = details; + for each (let key in Object.keys(rules)) { + channel.setResponseHeader(key, rules[key], false); + } +}
\ No newline at end of file |