MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / parse_range_header

Function parse_range_header

thirdparty/bottle/bottle.py:3384–3400  ·  view source on GitHub ↗

Yield (start, end) ranges parsed from a HTTP Range header. Skip unsatisfiable ranges. The end index is non-inclusive.

(header, maxlen=0)

Source from the content-addressed store, hash-verified

3382
3383
3384def parse_range_header(header, maxlen=0):
3385 """ Yield (start, end) ranges parsed from a HTTP Range header. Skip
3386 unsatisfiable ranges. The end index is non-inclusive."""
3387 if not header or header[:6] != 'bytes=': return
3388 ranges = [r.split('-', 1) for r in header[6:].split(',') if '-' in r]
3389 for start, end in ranges:
3390 try:
3391 if not start: # bytes=-100 -> last 100 bytes
3392 start, end = max(0, maxlen - int(end)), maxlen
3393 elif not end: # bytes=100- -> all but the first 99 bytes
3394 start, end = int(start), maxlen
3395 else: # bytes=100-200 -> bytes 100-200 (inclusive)
3396 start, end = int(start), min(int(end) + 1, maxlen)
3397 if 0 <= start < end <= maxlen:
3398 yield start, end
3399 except ValueError:
3400 pass
3401
3402
3403#: Header tokenizer used by _parse_http_header()

Callers 1

static_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…