code: static BlockLocation[] fixBlockLocations(BlockLocation[] locations,
                                             long start,
                                             long len,
                                             long fileOffsetInHar) {
      // offset 1 past last byte of desired range
      long end = start + len;
      
      for (BlockLocation location : locations) {
        // offset of part block relative to beginning of desired file
        // (may be negative if file starts in this part block)
        long harBlockStart = location.getOffset() - fileOffsetInHar;
        // offset 1 past last byte of har block relative to beginning of
        // desired file
        long harBlockEnd = harBlockStart + location.getLength();
        
        if (start > harBlockStart) {
          // desired range starts after beginning of this har block
          // fix offset to beginning of relevant range (relative to desired file)
          location.setOffset(start);
          // fix length to relevant portion of har block
          location.setLength(location.getLength() - (start - harBlockStart));
        } else {
          // desired range includes beginning of this har block
          location.setOffset(harBlockStart);
        }
        
        if (harBlockEnd > end) {
          // range ends before end of this har block
          // fix length to remove irrelevant portion at the end
          location.setLength(location.getLength() - (harBlockEnd - end));
        }
      }
      
      return locations;
    }
docs: Fix offset and length of block locations.
  Note that this method modifies the original array.
  @param locations block locations of har part file
  @param start the start of the desired range in the contained file
  @param len the length of the desired range
  @param fileOffsetInHar the offset of the desired file in the har part file
  @return block locations with fixed offset and length