This is an automated email from the ASF dual-hosted git repository. rob pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
commit cc72b9bf3ad57f67c277482759e83a8aeed1cb06 Author: Jan van Doorn <j...@knutsel.com> AuthorDate: Fri May 25 16:24:06 2018 -0600 Fix range from end use-case --- grove/plugin/range_req_handler.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grove/plugin/range_req_handler.go b/grove/plugin/range_req_handler.go index bdc1e07..cbb9a2a 100644 --- a/grove/plugin/range_req_handler.go +++ b/grove/plugin/range_req_handler.go @@ -166,6 +166,10 @@ func rangeReqHandleBeforeRespond(icfg interface{}, d BeforeRespondData) { if thisRange.End == -1 || thisRange.End >= totalContentLength { // if the end range is "", or too large serve until the end thisRange.End = totalContentLength - 1 } + if thisRange.Start == -1 { + thisRange.Start = totalContentLength - thisRange.End + thisRange.End = totalContentLength - 1 + } rangeString := "bytes " + strconv.FormatInt(thisRange.Start, 10) + "-" + strconv.FormatInt(thisRange.End, 10) log.Debugf("range:%d-%d\n", thisRange.Start, thisRange.End) @@ -174,7 +178,6 @@ func rangeReqHandleBeforeRespond(icfg interface{}, d BeforeRespondData) { body = append(body, []byte("Content-type: "+originalContentType+"%s\r\n")...) body = append(body, []byte("Content-range: "+rangeString+"\r\n\r\n")...) } else { - log.Debugf("Adding Range Header (should only happen once: %s\n", rangeString+"/"+strconv.FormatInt(totalContentLength, 10)) d.Hdr.Add("Content-Range", rangeString+"/"+strconv.FormatInt(totalContentLength, 10)) } bSlice := (*d.Body)[thisRange.Start : thisRange.End+1] @@ -194,7 +197,7 @@ func parseRange(rangeString string) (byteRange, error) { var bRange byteRange if parts[0] == "" { - bRange.Start = 0 + bRange.Start = -1 // -1 means from the end } else { start, err := strconv.ParseInt(parts[0], 10, 64) if err != nil { -- To stop receiving notification emails like this one, please contact r...@apache.org.