def __parse_request_range(range_header_text):
 left = None
 right = None
 if (not range_header_text):
  return (left, right)
 range_header_text = range_header_text.strip()
 if (not range_header_text.startswith('bytes')):
  return (left, right)
 components = range_header_text.split('=')
 if (len(components) != 2):
  return (left, right)
 components = components[1].split('-')
 try:
  right = int(components[1])
 except:
  pass
 try:
  left = int(components[0])
 except:
  pass
 return (left, right)

def __parse_request_range ( range_header_text ) : left = None right = None if ( not range_header_text ) : return ( left , right ) range_header_text = range_header_text . strip ( ) if ( not range_header_text . startswith ( 'bytes' ) ) : return ( left , right ) components = range_header_text . split ( '=' ) if ( len ( components ) != 2 ) : return ( left , right ) components = components [ 1 ] . split ( '-' ) try : right = int ( components [ 1 ] ) except : pass try : left = int ( components [ 0 ] ) except : pass return ( left , right )
return a tuple describing the byte range requested in a get request if the range is open ended on the left or right side .