Skip to content

Commit 21e0cdb

Browse files
committed
Improve code.
1 parent 5eff8c3 commit 21e0cdb

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

index.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5562,49 +5562,49 @@ F.notModified = function(req, res, compare, strict) {
55625562

55635563
F.responseCode = function(req, res, code, problem) {
55645564
res.options.code = code;
5565-
res.options.problem = problem;
5565+
problem && (res.options.problem = problem);
55665566
res.$throw();
55675567
return F;
55685568
};
55695569

55705570
F.response400 = function(req, res, problem) {
55715571
res.options.code = 400;
5572-
res.options.problem = problem;
5572+
problem && (res.options.problem = problem);
55735573
res.$throw();
55745574
return F;
55755575
};
55765576

55775577
F.response401 = function(req, res, problem) {
55785578
res.options.code = 401;
5579-
res.options.problem = problem;
5579+
problem && (res.options.problem = problem);
55805580
res.$throw();
55815581
return F;
55825582
};
55835583

55845584
F.response403 = function(req, res, problem) {
55855585
res.options.code = 403;
5586-
res.options.problem = problem;
5586+
problem && (res.options.problem = problem);
55875587
res.$throw();
55885588
return F;
55895589
};
55905590

55915591
F.response404 = function(req, res, problem) {
55925592
res.options.code = 404;
5593-
res.options.problem = problem;
5593+
problem && (res.options.problem = problem);
55945594
res.$throw();
55955595
return F;
55965596
};
55975597

55985598
F.response408 = function(req, res, problem) {
55995599
res.options.code = 408;
5600-
res.options.problem = problem;
5600+
problem && (res.options.problem = problem);
56015601
res.$throw();
56025602
return F;
56035603
};
56045604

56055605
F.response431 = function(req, res, problem) {
56065606
res.options.code = 431;
5607-
res.options.problem = problem;
5607+
problem && (res.options.problem = problem);
56085608
res.$throw();
56095609
return F;
56105610
};
@@ -5616,7 +5616,7 @@ F.response500 = function(req, res, error) {
56165616

56175617
F.response501 = function(req, res, problem) {
56185618
res.options.code = 501;
5619-
res.options.problem = problem;
5619+
problem && (res.options.problem = problem);
56205620
res.$throw();
56215621
return F;
56225622
};
@@ -6179,7 +6179,7 @@ F.listener = function(req, res) {
61796179
if (F._length_wait)
61806180
return F.response503(req, res);
61816181
else if (!req.host) // HTTP 1.0 without host
6182-
return F.response400(req, res);
6182+
return res.throw400();
61836183

61846184
var headers = req.headers;
61856185
req.$protocol = req.connection.encrypted || headers['x-forwarded-protocol'] === 'https' ? 'https' : 'http';
@@ -9290,7 +9290,7 @@ Subscribe.prototype.doEnd = function() {
92909290
self.route = route;
92919291
self.execute(431, true);
92929292
} else
9293-
F.response431(req, res);
9293+
rers.throw431();
92949294

92959295
return self;
92969296
}
@@ -11931,6 +11931,7 @@ Controller.prototype.baa = function(label) {
1193111931
res.options.body = '401: NOT AUTHORIZED';
1193211932
res.options.compress = false;
1193311933
res.options.headers = headers;
11934+
res.options.type = CONTENTTYPE_TEXTPLAIN;
1193411935
res.$text();
1193511936
self.cancel();
1193611937
return null;
@@ -14695,7 +14696,7 @@ http.ServerResponse.prototype.$text = function() {
1469514696
if (REG_TEXTAPPLICATION.test(options.type))
1469614697
options.type += '; charset=utf-8';
1469714698

14698-
headers[RESPONSE_HEADER_CONTENTTYPE] = options.type || CONTENTTYPE_TEXTPLAIN;
14699+
headers[RESPONSE_HEADER_CONTENTTYPE] = options.type;
1469914700

1470014701
if (options.headers)
1470114702
headers = U.extend_headers(headers, options.headers);

0 commit comments

Comments
 (0)