Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#11850 closed defect (fixed)

Rest range incorrect for count < 2

Reported by: gary.bishop.unc Owned by: Kris Zyp
Priority: high Milestone: 1.6
Component: General Version: 1.5
Keywords: Cc: Dustin Machi
Blocked By: Blocking:

Description

In dojox/rpc/Rest.js, on line 99 when count is 0 or 1 the resulting Range header will be incorrect. Assuming start === 0, the current code produces items=0- for count === 0 and count === 1. The correct value is items=0-0 for both of those cases.

I offer the following replacement for the super long current line:

if (args && (args.start >= 0 || args.count >= 0)) {
    var start = args.start || 0;
    var range = 'items=' + start + '-';
    if (args.count !== undefined && args.count != Infinity) {
        if (args.count === 0) {
             // minimum is one because last-pos must be >= first-pos
             // according to 14.35 in http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
            range += start;
        } else {
            range += args.count + start - 1;
        }
    }
    request.headers.Range = range;
}

Change History (4)

comment:1 Changed 9 years ago by Adam Peller

Cc: Dustin Machi added
Owner: changed from anonymous to Kris Zyp

comment:2 Changed 9 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

(In [23369]) Fix range handling when count is 0 or 1, fixes #11850

comment:3 Changed 9 years ago by Kris Zyp

(In [23370]) Fix range handling when count is 0 or 1, refs #11850

comment:4 Changed 9 years ago by Adam Peller

Milestone: tbd1.6
Note: See TracTickets for help on using tickets.