(name, range, headers, res)
| 18581 | } |
| 18582 | |
| 18583 | function $file_range(name, range, headers, res) { |
| 18584 | |
| 18585 | var arr = range.replace(REG_RANGE, '').split('-'); |
| 18586 | var beg = +arr[0] || 0; |
| 18587 | var end = +arr[1] || 0; |
| 18588 | var total = F.temporary.range[name]; |
| 18589 | |
| 18590 | if (!total) { |
| 18591 | total = Fs.statSync(name).size; |
| 18592 | RELEASE && (F.temporary.range[name] = total); |
| 18593 | } |
| 18594 | |
| 18595 | if (end === 0) |
| 18596 | end = total - 1; |
| 18597 | |
| 18598 | if (beg > end) { |
| 18599 | beg = 0; |
| 18600 | end = total - 1; |
| 18601 | } |
| 18602 | |
| 18603 | if (end > total) |
| 18604 | end = total - 1; |
| 18605 | |
| 18606 | var length = (end - beg) + 1; |
| 18607 | |
| 18608 | headers[HEADER_LENGTH] = length; |
| 18609 | headers['Content-Range'] = 'bytes ' + beg + '-' + end + '/' + total; |
| 18610 | |
| 18611 | var req = res; |
| 18612 | F.stats.response.streaming++; |
| 18613 | |
| 18614 | if (req.method === 'HEAD') { |
| 18615 | res.writeHead(206, headers); |
| 18616 | res.end(); |
| 18617 | response_end(res); |
| 18618 | return F; |
| 18619 | } |
| 18620 | |
| 18621 | res.writeHead(206, headers); |
| 18622 | RANGE.start = beg; |
| 18623 | RANGE.end = end; |
| 18624 | fsStreamRead(name, RANGE, $file_range_callback, res); |
| 18625 | return F; |
| 18626 | } |
| 18627 | |
| 18628 | function $file_range_callback(stream, next, res) { |
| 18629 | framework_internal.onFinished(res, function() { |
no test coverage detected