req.protocol.js
This file
Path
test/req.protocol.js
65 lines · 1.4 KiB · JavaScript
Last changed by
remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
History of this fileTake it
The walk stopped after 200 commits: lines older than 0b4e2df point at it.
add "view" constructor setting to override view behaviourCaridy Patinobefore adoption0b4e2df
lines 1–2why, one step back12var express = require('../')remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
line 3why, one step back3 , request = require('supertest');add "view" constructor setting to override view behaviourCaridy Patinobefore adoption0b4e2df
lines 4–65why, one step back45describe('req', function(){6 describe('.protocol', function(){7 it('should return the protocol string', function(done){8 var app = express();910 app.use(function(req, res){11 res.end(req.protocol);12 });1314 request(app)15 .get('/')16 .expect('http', done);17 })1819 describe('when "trust proxy" is enabled', function(){20 it('should respect X-Forwarded-Proto', function(done){21 var app = express();2223 app.enable('trust proxy');2425 app.use(function(req, res){26 res.end(req.protocol);27 });2829 request(app)30 .get('/')31 .set('X-Forwarded-Proto', 'https')32 .expect('https', done);33 })3435 it('should default to http', function(done){36 var app = express();3738 app.enable('trust proxy');3940 app.use(function(req, res){41 res.end(req.protocol);42 });4344 request(app)45 .get('/')46 .expect('http', done);47 })48 })4950 describe('when "trust proxy" is disabled', function(){51 it('should ignore X-Forwarded-Proto', function(done){52 var app = express();5354 app.use(function(req, res){55 res.end(req.protocol);56 });5758 request(app)59 .get('/')60 .set('X-Forwarded-Proto', 'https')61 .expect('http', done);62 })63 })64 })65})