// Path: wayback-core/src/main/java/org/archive/wayback/exception/RangeNotSatisfiableException.java
// public class RangeNotSatisfiableException extends SpecificCaptureReplayException {
// 	private static final long serialVersionUID = 1L;
// 
// 	private Resource origResource;
// 	private long[][] requestedRanges;
// 
// 	public RangeNotSatisfiableException(Resource origResource, long[][] requestedRanges, String message) {
// 		super(message, "RangeNotSatisfiable");
// 		this.origResource = origResource;
// 		this.requestedRanges = requestedRanges;
// 	}
// 
// 	@Override
// 	public int getStatus() {
// 		return HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE;
// 	}
// 
// 	public Resource getOrigResource() {
// 		return origResource;
// 	}
// 
// 	public long[][] getRequestedRanges() {
// 		return requestedRanges;
// 	}
// }


import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.archive.wayback.core.Resource;
import org.archive.wayback.exception.RangeNotSatisfiableException;
import com.google.common.io.ByteStreams;
		String contentRange = String.format("bytes %d-%d/%d", start,
			stop - 1, availRange[2]);
		HttpHeaderOperation.replaceHeader(httpHeaders,
			HttpHeaderOperation.HTTP_CONTENT_RANGE_HEADER, contentRange);
		HttpHeaderOperation
			.replaceHeader(httpHeaders, HttpHeaderOperation.HTTP_LENGTH_HEADER,
				Long.toString(stop - start));
	}

	/**
	 * Look at resource HTTP header fields and determine the byte range available.
	 * @return array with three long values:
	 * <ol>
	 * <li><em>offset of first available byte</em>,
	 * <li><em>offset of last available byte</em> + 1,
	 * <li><em>instance-length</em>
	 * </ol>
	 * Note this method returns {@code null} for {@code multipart/byteranges}
	 * response.
	 */
	protected long[] availableRange() {
		// for revisit capture, HTTP headers comes from revisiting resource.
		// it should be okay to assume revisited resource has exactly the same
		// Content-Range header field.
		Map<String, String> respHeaders = origResource.getHttpHeaders();
		long[] contentRange = HttpHeaderOperation
			.getContentRange(respHeaders);
		long availStart, availStop, contentLength;
		if (contentRange == null) {
			// regular 200 response (or Content-Range is invalid)
// Path: wayback-core/src/main/java/org/archive/wayback/exception/RangeNotSatisfiableException.java
// public class RangeNotSatisfiableException extends SpecificCaptureReplayException {
// 	private static final long serialVersionUID = 1L;
// 
// 	private Resource origResource;
// 	private long[][] requestedRanges;
// 
// 	public RangeNotSatisfiableException(Resource origResource, long[][] requestedRanges, String message) {
// 		super(message, "RangeNotSatisfiable");
// 		this.origResource = origResource;
// 		this.requestedRanges = requestedRanges;
// 	}
// 
// 	@Override
// 	public int getStatus() {
// 		return HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE;
// 	}
// 
// 	public Resource getOrigResource() {
// 		return origResource;
// 	}
// 
// 	public long[][] getRequestedRanges() {
// 		return requestedRanges;
// 	}
// }


// Path: wayback-core/src/main/java/org/archive/wayback/replay/RangeResource.java
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.archive.wayback.core.Resource;
import org.archive.wayback.exception.RangeNotSatisfiableException;
import com.google.common.io.ByteStreams;

		String contentRange = String.format("bytes %d-%d/%d", start,
			stop - 1, availRange[2]);
		HttpHeaderOperation.replaceHeader(httpHeaders,
			HttpHeaderOperation.HTTP_CONTENT_RANGE_HEADER, contentRange);
		HttpHeaderOperation
			.replaceHeader(httpHeaders, HttpHeaderOperation.HTTP_LENGTH_HEADER,
				Long.toString(stop - start));
	}

	/**
	 * Look at resource HTTP header fields and determine the byte range available.
	 * @return array with three long values:
	 * <ol>
	 * <li><em>offset of first available byte</em>,
	 * <li><em>offset of last available byte</em> + 1,
	 * <li><em>instance-length</em>
	 * </ol>
	 * Note this method returns {@code null} for {@code multipart/byteranges}
	 * response.
	 */
	protected long[] availableRange() {
		// for revisit capture, HTTP headers comes from revisiting resource.
		// it should be okay to assume revisited resource has exactly the same
		// Content-Range header field.
		Map<String, String> respHeaders = origResource.getHttpHeaders();
		long[] contentRange = HttpHeaderOperation
			.getContentRange(respHeaders);
		long availStart, availStop, contentLength;
		if (contentRange == null) {
			// regular 200 response (or Content-Range is invalid)
			String clen = HttpHeaderOperation.getContentLength(respHeaders);