Skip to content

Commit 9282395

Browse files
committed
prettier
1 parent 2b8f43b commit 9282395

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

index.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Module dependencies.
43
*/
@@ -23,10 +22,13 @@ module.exports = HttpsProxyAgent;
2322
* @api public
2423
*/
2524

26-
function HttpsProxyAgent (opts) {
25+
function HttpsProxyAgent(opts) {
2726
if (!(this instanceof HttpsProxyAgent)) return new HttpsProxyAgent(opts);
2827
if ('string' == typeof opts) opts = url.parse(opts);
29-
if (!opts) throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
28+
if (!opts)
29+
throw new Error(
30+
'an HTTP(S) proxy server `host` and `port` must be specified!'
31+
);
3032
debug('creating new HttpsProxyAgent instance: %o', opts);
3133
Agent.call(this, opts);
3234

@@ -57,7 +59,7 @@ inherits(HttpsProxyAgent, Agent);
5759
* @api public
5860
*/
5961

60-
HttpsProxyAgent.prototype.callback = function connect (req, opts, fn) {
62+
HttpsProxyAgent.prototype.callback = function connect(req, opts, fn) {
6163
var proxy = this.proxy;
6264

6365
// create a socket connection to the proxy server
@@ -75,34 +77,34 @@ HttpsProxyAgent.prototype.callback = function connect (req, opts, fn) {
7577
var buffers = [];
7678
var buffersLength = 0;
7779

78-
function read () {
80+
function read() {
7981
var b = socket.read();
8082
if (b) ondata(b);
8183
else socket.once('readable', read);
8284
}
8385

84-
function cleanup () {
86+
function cleanup() {
8587
socket.removeListener('data', ondata);
8688
socket.removeListener('end', onend);
8789
socket.removeListener('error', onerror);
8890
socket.removeListener('close', onclose);
8991
socket.removeListener('readable', read);
9092
}
9193

92-
function onclose (err) {
94+
function onclose(err) {
9395
debug('onclose had error %o', err);
9496
}
9597

96-
function onend () {
98+
function onend() {
9799
debug('onend');
98100
}
99101

100-
function onerror (err) {
102+
function onerror(err) {
101103
cleanup();
102104
fn(err);
103105
}
104106

105-
function ondata (b) {
107+
function ondata(b) {
106108
buffers.push(b);
107109
buffersLength += b.length;
108110
var buffered = Buffer.concat(buffers, buffersLength);
@@ -133,9 +135,12 @@ HttpsProxyAgent.prototype.callback = function connect (req, opts, fn) {
133135
if (opts.secureEndpoint) {
134136
// since the proxy is connecting to an SSL server, we have
135137
// to upgrade this socket connection to an SSL connection
136-
debug('upgrading proxy-connected socket to TLS connection: %o', opts.host);
138+
debug(
139+
'upgrading proxy-connected socket to TLS connection: %o',
140+
opts.host
141+
);
137142
opts.socket = socket;
138-
opts.servername = opts.servername?opts.servername:opts.host;
143+
opts.servername = opts.servername || opts.host;
139144
opts.host = null;
140145
opts.hostname = null;
141146
opts.port = null;
@@ -159,7 +164,7 @@ HttpsProxyAgent.prototype.callback = function connect (req, opts, fn) {
159164
}
160165
}
161166

162-
function onsocket (socket) {
167+
function onsocket(socket) {
163168
// replay the "buffers" Buffer onto the `socket`, since at this point
164169
// the HTTP module machinery has been hooked up for the user
165170
if ('function' == typeof socket.ondata) {
@@ -192,11 +197,12 @@ HttpsProxyAgent.prototype.callback = function connect (req, opts, fn) {
192197

193198
var headers = Object.assign({}, proxy.headers);
194199
if (proxy.auth) {
195-
headers['Proxy-Authorization'] = 'Basic ' + new Buffer(proxy.auth).toString('base64');
200+
headers['Proxy-Authorization'] =
201+
'Basic ' + new Buffer(proxy.auth).toString('base64');
196202
}
197203
headers['Host'] = hostname;
198204
headers['Connection'] = 'close';
199-
Object.keys(headers).forEach(function (name) {
205+
Object.keys(headers).forEach(function(name) {
200206
msg += name + ': ' + headers[name] + '\r\n';
201207
});
202208

0 commit comments

Comments
 (0)