Skip to content
Myr

req.protocol.js

This file

Path

test/req.protocol.js

80 lines · 1.7 KiB · JavaScript

Last changed by

Merge tag '3.7.0'Douglas Christopher Wilsonbefore adoption097cd0c

History of this file

Take it

The walk stopped after 200 commits: lines older than 50cb62c point at it.

fix tests for should.jsJonathan Ongbefore adoption50cb62c

lines 1–2why, one step back
1
2var express = require('../')

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 3why, one step back
3 , request = require('supertest');

fix tests for should.jsJonathan Ongbefore adoption50cb62c

lines 4–34why, one step back
4
5describe('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 })34

Merge tag '3.7.0'Douglas Christopher Wilsonbefore adoption097cd0c

lines 35–49why, one step back
35 it('should ignore X-Forwarded-Proto if socket addr not trusted', function(done){
36 var app = express();3738 app.set('trust proxy', '10.0.0.1');3940 app.use(function(req, res){41 res.end(req.protocol);42 });4344 request(app)45 .get('/')46 .set('X-Forwarded-Proto', 'https')47 .expect('http', done);48 })49

fix tests for should.jsJonathan Ongbefore adoption50cb62c

lines 50–80why, one step back
50 it('should default to http', function(done){
51 var app = express();5253 app.enable('trust proxy');5455 app.use(function(req, res){56 res.end(req.protocol);57 });5859 request(app)60 .get('/')61 .expect('http', done);62 })63 })6465 describe('when "trust proxy" is disabled', function(){66 it('should ignore X-Forwarded-Proto', function(done){67 var app = express();6869 app.use(function(req, res){70 res.end(req.protocol);71 });7273 request(app)74 .get('/')75 .set('X-Forwarded-Proto', 'https')76 .expect('http', done);77 })78 })79 })80})