Single HTTP byte ranges
RangeTallow brings single-range HTTP handling into a Windows project conversation. Ask the connected model to work through inclusive bounds and empty resources, then review the code and response assumptions yourself.
import re
def byte_range(header, size):
if type(header) is not str or len(header) > 80 or type(size) is not int or not 0 <= size <= 10**12:
raise ValueError("range.input")
match = re.fullmatch(r"bytes=([0-9]*)-([0-9]*)", header)
if match is None or not any(match.groups()):
raise ValueError("range.syntax")
left, right = match.groups()
if not left:
suffix = int(right)
if suffix == 0 or size == 0:
return None
return max(0, size-suffix), size-1
start = int(left)
end = int(right) if right else size-1
if start >= size or end < start:
return None
return start, min(end, size-1)
Review before applying
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
Connection
Base URL, credentials and a reachable server.
Project
Test open ends and suffixes, clip an excessive end and return no interval for unsatisfiable requests while rejecting malformed or multiple ranges.
import re
def byte_range(header, size):
if type(header) is not str or len(header) > 80 or type(size) is not int or not 0 <= size <= 10**12:
raise ValueError("range.input")
match = re.fullmatch(r"bytes=([0-9]*)-([0-9]*)", header)
if match is None or not any(match.groups()):
raise ValueError("range.syntax")
left, right = match.groups()
if not left:
suffix = int(right)
if suffix == 0 or size == 0:
return None
return max(0, size-suffix), size-1
start = int(left)
end = int(right) if right else size-1
if start >= size or end < start:
return None
return start, min(end, size-1)
Keep a utility refactor faithful to the request it interprets
RangeTallow is AI coding software for reviewing utility changes in the context of the application that depends on them. Open the project on Windows and describe which behavior must stay stable through a refactor. Ask the model to inspect input parsing, returned values and the relevant caller together. That keeps a shorter implementation from silently changing the meaning of a request.
You might use byte_range.py to discuss how a suffix range is resolved against a known file size. Bring explicit examples for a normal range, an empty resource and a request outside the available content. Review what the helper returns before deciding how the response handler should use it. Treat range interpretation and response construction as related responsibilities with a boundary you can explain.
Test the proposed edit using your project environment, including the cases that distinguish malformed input from an unsatisfiable range. Inspect the response code that consumes the result so a new return convention does not produce misleading output. RangeTallow supports OpenAI-compatible or Anthropic connections, with credentials as required. Unrestricted models can be chosen when your endpoint offers them; context limits, tools and restrictions remain model- and server-dependent. The accepted request examples give the refactoring conversation a concrete measure of success.
Reviewing range-handling changes
Why distinguish malformed and unsatisfiable input?
They describe different conditions: a request may fail to match the accepted syntax or may ask for content unavailable at the known size. Specify how your helper represents each and inspect how the response handler uses that distinction.
Is a parsed range enough to build a correct response?
No. The caller must still construct the response according to its own contract and actual resource. Review how it uses the returned bounds, including body selection and status behavior, rather than treating successful parsing as completed integration.
What should a suffix example specify?
Give the requested suffix length, the known resource size and the expected inclusive bounds or rejection result. Include an empty resource case so the implementation cannot rely on there always being a last byte to select.
How can I keep the refactor focused?
Write down the current accepted cases and the intended change, if any. Ask for a proposal that preserves other behavior, then inspect the diff and run those cases through both the helper and its caller.
RangeTallow · Updated 2026-10-25