req.range.js
This file
Path
test/req.range.js
104 lines · 2.3 KiB · JavaScript
Last changed by
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
History of this fileTake it
The walk stopped after 200 commits: lines older than 2a0c35a point at it.
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
line 1why, one step back1'use strict'Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 2–3why, one step back23var express = require('..');Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 4why, one step back4var request = require('supertest')Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 5–7why, one step back56describe('req', function(){7 describe('.range(size)', function(){Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 8–18why, one step back8 it('should return parsed ranges', function (done) {9 var app = express()1011 app.use(function (req, res) {12 res.json(req.range(120))13 })1415 request(app)16 .get('/')17 .set('Range', 'bytes=0-50,51-100')18 .expect(200, '[{"start":0,"end":50},{"start":51,"end":100}]', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 19–20why, one step back19 })20Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 21–31why, one step back21 it('should cap to the given size', function (done) {22 var app = express()2324 app.use(function (req, res) {25 res.json(req.range(75))26 })2728 request(app)29 .get('/')30 .set('Range', 'bytes=0-100')31 .expect(200, '[{"start":0,"end":74}]', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 32–33why, one step back32 })33Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 34–44why, one step back34 it('should cap to the given size when open-ended', function (done) {35 var app = express()3637 app.use(function (req, res) {38 res.json(req.range(75))39 })4041 request(app)42 .get('/')43 .set('Range', 'bytes=0-')44 .expect(200, '[{"start":0,"end":74}]', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 45–46why, one step back45 })46Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 47–57why, one step back47 it('should have a .type', function (done) {48 var app = express()4950 app.use(function (req, res) {51 res.json(req.range(120).type)52 })5354 request(app)55 .get('/')56 .set('Range', 'bytes=0-100')57 .expect(200, '"bytes"', done)Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 58why, one step back58 })Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 59–83why, one step back5960 it('should accept any type', function (done) {61 var app = express()6263 app.use(function (req, res) {64 res.json(req.range(120).type)65 })6667 request(app)68 .get('/')69 .set('Range', 'users=0-2')70 .expect(200, '"users"', done)71 })7273 it('should return undefined if no range', function (done) {74 var app = express()7576 app.use(function (req, res) {77 res.send(String(req.range(120)))78 })7980 request(app)81 .get('/')82 .expect(200, 'undefined', done)83 })Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
lines 84–87why, one step back84 })8586 describe('.range(size, options)', function(){87 describe('with "combine: true" option', function(){Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 88–100why, one step back88 it('should return combined ranges', function (done) {89 var app = express()9091 app.use(function (req, res) {92 res.json(req.range(120, {93 combine: true94 }))95 })9697 request(app)98 .get('/')99 .set('Range', 'bytes=0-50,51-100')100 .expect(200, '[{"start":0,"end":100}]', done)Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 101why, one step back101 })Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 102–104why, one step back102 })103 })104})