Skip to content
Myr

Added `req.range(size)`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent e6129d8 · Browse files · 3 files+55 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+55 added−0 removed

  • tests:+31 added−0 removed
  • other:+24 added−0 removed

3 files+55 added−0 removed

modified:lib/request.js+23 added
5 unmodified lines
6var http = require('http')7 , utils = require('./utils')8 , connect = require('connect')9 , fresh = require('fresh')10 , parseRange = require('range-parser')11 , parse = connect.utils.parseUrl12 , mime = connect.mime;1314/**
118 unmodified lines
133 : true;134};135136/**137 * Parse Range header field,138 * capping to the given `size`.139 *140 * Unspecified ranges such as "0-" require141 * knowledge of your resource length. In142 * the case of a byte range this is of course143 * the total number of bytes. If the Range144 * header field is not given `undefined` is returned,145 * on failure `null` is returned.146 *147 * @param {Number} size148 * @return {Array}149 * @api public150 */151152req.range = function(size){153 var range = this.get('Range');154 if (!range) return;155 return parseRange(size, range);156};157158/**159 * Return an array of Accepted media types160 * ordered from highest quality to lowest.161 *162 * Examples:
291 unmodified lines
added:test/req.range.js+31 added
modified:package.json+1 added