'Take the requested range(s) from the client and convert it to range(s)
to be sent to the object servers.
This includes widening requested ranges to full segments, then
converting those ranges to fragments so that we retrieve the minimum
number of fragments from the object server.
Mutates the request passed in.
Returns a list of range specs (dictionaries with the different byte
indices in them).'

def _convert_range(self, req, policy):

    segment_size = policy.ec_segment_size
    fragment_size = policy.fragment_size
    range_specs = []
    new_ranges = []
    for (client_start, client_end) in req.range.ranges:
        (segment_start, segment_end) = client_range_to_segment_range(client_start, client_end, segment_size)
        (fragment_start, fragment_end) = segment_range_to_fragment_range(segment_start, segment_end, segment_size, fragment_size)
        new_ranges.append((fragment_start, fragment_end))
        range_specs.append({'req_client_start': client_start, 'req_client_end': client_end, 'req_segment_start': segment_start, 'req_segment_end': segment_end, 'req_fragment_start': fragment_start, 'req_fragment_end': fragment_end})
    req.range = ('bytes=' + ','.join((('%s-%s' % ((s if (s is not None) else ''), (e if (e is not None) else ''))) for (s, e) in new_ranges)))
    return range_specs
