mr.rager

0.0.2 • Public • Published

Mr.Rager

Mr.Rager is a very relaxed parser written in Javascript for getting range representations from Content-Range headers. Mr.Rager won't yell about much, and if he does something went seriously wrong. If the parser experiences anything out of the ordinary it will gently degrade in behaviour of parsing, and in the instance of some really cooky headers, it will just give back a range representative of the whole file.

Usage

parse(rangeHeader, size)
returns an array where each element is an 2-element object of parsed values, the 'begining' key being the start of the range, and the 'end' key being the end of the range

Example

var http = require('http');
 
var server = http.createServer(function(req, res){
    res.writeHead(200, {'content-type' : 'application/json'});
    var parsed = parse(req.headers['range'], 1000);
    console.log('Parsed "range" header as:', parsed);
    res.end();
    setTimeout(function(){
        process.exit(0);
    }, 3000);
}).listen(8000, function(){
    console.log('Listening on port 8000');
});
 
http.request({
    host: 'localhost',
    method: 'GET',
    port: 8000,
    headers: {'range': 'bytes=500-'}}).end();

Readme

Keywords

none

Package Sidebar

Install

npm i mr.rager

Weekly Downloads

1

Version

0.0.2

License

BSD

Last publish

Collaborators

  • rubberduckie