Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 454c4b2 point at it.

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 1why, one step back
1'use strict'

Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2

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

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

line 4why, one step back
4var request = require('supertest')

Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2

lines 5–7why, one step back
5
6describe('req', function(){7 describe('.range(size)', function(){

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 8–18why, one step back
8 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)

Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2

lines 19–20why, one step back
19 })
20

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 21–31why, one step back
21 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)

Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2

lines 32–33why, one step back
32 })
33

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 34–44why, one step back
34 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)

Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2

lines 45–46why, one step back
45 })
46

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 47–57why, one step back
47 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 back
58 })

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 59–83why, one step back
59
60 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 back
84 })
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 back
88 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 back
101 })

Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2

lines 102–104why, one step back
102 })
103 })104})