Produced by Araxis Merge on 10/24/2017 6:38:25 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | CHAMP_VA1.zip\CHAMP_VA1\node_modules\cheerio\node_modules\jsdom\node_modules\request\node_modules\tunnel-agent | index.js | Mon Oct 16 21:06:50 2017 UTC |
| 2 | CHAMP_VA1.zip\CHAMP_VA1\node_modules\cheerio\node_modules\jsdom\node_modules\request\node_modules\tunnel-agent | index.js | Mon Oct 23 16:34:39 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 484 |
| Changed | 2 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | 'use stric t' | |
| 2 | ||
| 3 | var net = require('n et') | |
| 4 | , tls = require('t ls') | |
| 5 | , http = require(' http') | |
| 6 | , https = require( 'https') | |
| 7 | , events = require ('events') | |
| 8 | , assert = require ('assert') | |
| 9 | , util = require(' util') | |
| 10 | , Buffer = require ('safe-buf fer').Buff er | |
| 11 | ; | |
| 12 | ||
| 13 | exports.ht tpOverHttp = httpOve rHttp | |
| 14 | exports.ht tpsOverHtt p = httpsO verHttp | |
| 15 | exports.ht tpOverHttp s = httpOv erHttps | |
| 16 | exports.ht tpsOverHtt ps = https OverHttps | |
| 17 | ||
| 18 | ||
| 19 | function h ttpOverHtt p(options) { | |
| 20 | var agen t = new Tu nnelingAge nt(options ) | |
| 21 | agent.re quest = ht tp.request | |
| 22 | return a gent | |
| 23 | } | |
| 24 | ||
| 25 | function h ttpsOverHt tp(options ) { | |
| 26 | var agen t = new Tu nnelingAge nt(options ) | |
| 27 | agent.re quest = ht tp.request | |
| 28 | agent.cr eateSocket = createS ecureSocke t | |
| 29 | agent.defa ultPort = PORT | |
| 30 | return a gent | |
| 31 | } | |
| 32 | ||
| 33 | function h ttpOverHtt ps(options ) { | |
| 34 | var agen t = new Tu nnelingAge nt(options ) | |
| 35 | agent.re quest = ht tps.reques t | |
| 36 | return a gent | |
| 37 | } | |
| 38 | ||
| 39 | function h ttpsOverHt tps(option s) { | |
| 40 | var agen t = new Tu nnelingAge nt(options ) | |
| 41 | agent.re quest = ht tps.reques t | |
| 42 | agent.cr eateSocket = createS ecureSocke t | |
| 43 | agent.defa ultPort = PORT | |
| 44 | return a gent | |
| 45 | } | |
| 46 | ||
| 47 | ||
| 48 | function T unnelingAg ent(option s) { | |
| 49 | var self = this | |
| 50 | self.opt ions = opt ions || {} | |
| 51 | self.pro xyOptions = self.opt ions.proxy || {} | |
| 52 | self.max Sockets = self.optio ns.maxSock ets || htt p.Agent.de faultMaxSo ckets | |
| 53 | self.req uests = [] | |
| 54 | self.soc kets = [] | |
| 55 | ||
| 56 | self.on( 'free', fu nction onF ree(socket , host, po rt) { | |
| 57 | for (v ar i = 0, len = self .requests. length; i < len; ++i ) { | |
| 58 | var pending = self.reque sts[i] | |
| 59 | if ( pending.ho st === hos t && pendi ng.port == = port) { | |
| 60 | // Detect th e request to connect same orig in server, | |
| 61 | // reuse the connectio n. | |
| 62 | se lf.request s.splice(i , 1) | |
| 63 | pe nding.requ est.onSock et(socket) | |
| 64 | re turn | |
| 65 | } | |
| 66 | } | |
| 67 | socket .destroy() | |
| 68 | self.r emoveSocke t(socket) | |
| 69 | }) | |
| 70 | } | |
| 71 | util.inher its(Tunnel ingAgent, events.Eve ntEmitter) | |
| 72 | ||
| 73 | TunnelingA gent.proto type.addRe quest = fu nction add Request(re q, options ) { | |
| 74 | var self = this | |
| 75 | ||
| 76 | // Lega cy API: ad dRequest(r eq, host, port, path ) | |
| 77 | if (type of options === 'stri ng') { | |
| 78 | option s = { | |
| 79 | host : options, | |
| 80 | port : argument s[2], | |
| 81 | path : argument s[3] | |
| 82 | }; | |
| 83 | } | |
| 84 | ||
| 85 | if (self .sockets.l ength >= t his.maxSoc kets) { | |
| 86 | // We are over l imit so we 'll add it to the qu eue. | |
| 87 | self.r equests.pu sh({host: options.ho st, port: options.po rt, reques t: req}) | |
| 88 | return | |
| 89 | } | |
| 90 | ||
| 91 | // If we are under maxSocket s create a new one. | |
| 92 | self.cre ateConnect ion({host: options.h ost, port: options.p ort, reque st: req}) | |
| 93 | } | |
| 94 | ||
| 95 | TunnelingA gent.proto type.creat eConnectio n = functi on createC onnection( pending) { | |
| 96 | var self = this | |
| 97 | ||
| 98 | self.cre ateSocket( pending, f unction(so cket) { | |
| 99 | socket .on('free' , onFree) | |
| 100 | socket .on('close ', onClose OrRemove) | |
| 101 | socket .on('agent Remove', o nCloseOrRe move) | |
| 102 | pendin g.request. onSocket(s ocket) | |
| 103 | ||
| 104 | functi on onFree( ) { | |
| 105 | self .emit('fre e', socket , pending. host, pend ing.port) | |
| 106 | } | |
| 107 | ||
| 108 | functi on onClose OrRemove(e rr) { | |
| 109 | self .removeSoc ket(socket ) | |
| 110 | sock et.removeL istener('f ree', onFr ee) | |
| 111 | sock et.removeL istener('c lose', onC loseOrRemo ve) | |
| 112 | sock et.removeL istener('a gentRemove ', onClose OrRemove) | |
| 113 | } | |
| 114 | }) | |
| 115 | } | |
| 116 | ||
| 117 | TunnelingA gent.proto type.creat eSocket = function c reateSocke t(options, cb) { | |
| 118 | var self = this | |
| 119 | var plac eholder = {} | |
| 120 | self.soc kets.push( placeholde r) | |
| 121 | ||
| 122 | var conn ectOptions = mergeOp tions({}, self.proxy Options, | |
| 123 | { meth od: 'CONNE CT' | |
| 124 | , path : options. host + ':' + options .port | |
| 125 | , agen t: false | |
| 126 | } | |
| 127 | ) | |
| 128 | if (conn ectOptions .proxyAuth ) { | |
| 129 | connec tOptions.h eaders = c onnectOpti ons.header s || {} | |
| 130 | connec tOptions.h eaders['Pr oxy-Author ization'] = 'Basic ' + | |
| 131 | Bu ffer.from( connectOpt ions.proxy Auth).toSt ring('base 64') | |
| 132 | } | |
| 133 | ||
| 134 | debug('m aking CONN ECT reques t') | |
| 135 | var conn ectReq = s elf.reques t(connectO ptions) | |
| 136 | connectR eq.useChun kedEncodin gByDefault = false / / for v0.6 | |
| 137 | connectR eq.once('r esponse', onResponse ) // for v 0.6 | |
| 138 | connectR eq.once('u pgrade', o nUpgrade) // for v 0.6 | |
| 139 | connectR eq.once('c onnect', o nConnect) // for v 0.7 or lat er | |
| 140 | connectR eq.once('e rror', onE rror) | |
| 141 | connectR eq.end() | |
| 142 | ||
| 143 | function onRespons e(res) { | |
| 144 | // Ver y hacky. T his is nec essary to avoid http -parser le aks. | |
| 145 | res.up grade = tr ue | |
| 146 | } | |
| 147 | ||
| 148 | function onUpgrade (res, sock et, head) { | |
| 149 | // Hac ky. | |
| 150 | proces s.nextTick (function( ) { | |
| 151 | onCo nnect(res, socket, h ead) | |
| 152 | }) | |
| 153 | } | |
| 154 | ||
| 155 | function onConnect (res, sock et, head) { | |
| 156 | connec tReq.remov eAllListen ers() | |
| 157 | socket .removeAll Listeners( ) | |
| 158 | ||
| 159 | if (re s.statusCo de === 200 ) { | |
| 160 | asse rt.equal(h ead.length , 0) | |
| 161 | debu g('tunneli ng connect ion has es tablished' ) | |
| 162 | self .sockets[s elf.socket s.indexOf( placeholde r)] = sock et | |
| 163 | cb(s ocket) | |
| 164 | } else { | |
| 165 | debu g('tunneli ng socket could not be establi shed, stat usCode=%d' , res.stat usCode) | |
| 166 | var error = ne w Error('t unneling s ocket coul d not be e stablished , ' + 'sta tusCode=' + res.stat usCode) | |
| 167 | erro r.code = ' ECONNRESET ' | |
| 168 | opti ons.reques t.emit('er ror', erro r) | |
| 169 | self .removeSoc ket(placeh older) | |
| 170 | } | |
| 171 | } | |
| 172 | ||
| 173 | function onError(c ause) { | |
| 174 | connec tReq.remov eAllListen ers() | |
| 175 | ||
| 176 | debug( 'tunneling socket co uld not be establish ed, cause= %s\n', cau se.message , cause.st ack) | |
| 177 | var er ror = new Error('tun neling soc ket could not be est ablished, ' + 'cause =' + cause .message) | |
| 178 | error. code = 'EC ONNRESET' | |
| 179 | option s.request. emit('erro r', error) | |
| 180 | self.r emoveSocke t(placehol der) | |
| 181 | } | |
| 182 | } | |
| 183 | ||
| 184 | TunnelingA gent.proto type.remov eSocket = function r emoveSocke t(socket) { | |
| 185 | var pos = this.soc kets.index Of(socket) | |
| 186 | if (pos === -1) re turn | |
| 187 | ||
| 188 | this.soc kets.splic e(pos, 1) | |
| 189 | ||
| 190 | var pend ing = this .requests. shift() | |
| 191 | if (pend ing) { | |
| 192 | // If we have pe nding requ ests and a socket ge ts closed a new one | |
| 193 | // nee ds to be c reated to take over in the poo l for the one that c losed. | |
| 194 | this.c reateConne ction(pend ing) | |
| 195 | } | |
| 196 | } | |
| 197 | ||
| 198 | function c reateSecur eSocket(op tions, cb) { | |
| 199 | var self = this | |
| 200 | Tunnelin gAgent.pro totype.cre ateSocket. call(self, options, function(s ocket) { | |
| 201 | // 0 i s dummy po rt for v0. 6 | |
| 202 | var se cureSocket = tls.con nect(0, me rgeOptions ({}, self. options, | |
| 203 | { se rvername: options.ho st | |
| 204 | , so cket: sock et | |
| 205 | } | |
| 206 | )) | |
| 207 | self.s ockets[sel f.sockets. indexOf(so cket)] = s ecureSocke t | |
| 208 | cb(sec ureSocket) | |
| 209 | }) | |
| 210 | } | |
| 211 | ||
| 212 | ||
| 213 | function m ergeOption s(target) { | |
| 214 | for (var i = 1, le n = argume nts.length ; i < len; ++i) { | |
| 215 | var ov errides = arguments[ i] | |
| 216 | if (ty peof overr ides === ' object') { | |
| 217 | var keys = Obj ect.keys(o verrides) | |
| 218 | for (var j = 0 , keyLen = keys.leng th; j < ke yLen; ++j) { | |
| 219 | va r k = keys [j] | |
| 220 | if (override s[k] !== u ndefined) { | |
| 221 | target[k] = override s[k] | |
| 222 | } | |
| 223 | } | |
| 224 | } | |
| 225 | } | |
| 226 | return t arget | |
| 227 | } | |
| 228 | ||
| 229 | ||
| 230 | var debug | |
| 231 | if (proces s.env.NODE _DEBUG && /\btunnel\ b/.test(pr ocess.env. NODE_DEBUG )) { | |
| 232 | debug = function() { | |
| 233 | var ar gs = Array .prototype .slice.cal l(argument s) | |
| 234 | if (ty peof args[ 0] === 'st ring') { | |
| 235 | args [0] = 'TUN NEL: ' + a rgs[0] | |
| 236 | } else { | |
| 237 | args .unshift(' TUNNEL:') | |
| 238 | } | |
| 239 | consol e.error.ap ply(consol e, args) | |
| 240 | } | |
| 241 | } else { | |
| 242 | debug = function() {} | |
| 243 | } | |
| 244 | exports.de bug = debu g // for t est |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.