utils.py
def prioritizeEncoding(acceptVal):
	"""
	takes in accept-encoding header value(str) and returns 
	which encoding to use according to q priority
	"""
	if(acceptVal == ""):
		return "identity"
	allEncodings = [
		"br",
		"compress",
		"deflate",
		"gzip",
		"exi",
		"pack200-gzip",
		"x-compress",
		"x-gzip",
		"zstd"
	]
	priority=dict()
	tmp = acceptVal.split(',')
	starPriority = 0
	seenEncodings = []
	pflag = 0
	for i in tmp:
		i = i.strip()
		pair = i.split(';')
		encoding = pair[0].strip()
		seenEncodings.append(encoding)
		if len(pair) == 1:
			pair.append("q=1.0")
		q = float(pair[1].split("=")[1].strip())
		if(q == 0.0):
			if(encoding=="identity"):
				pflag = 1
			continue
		if(encoding!="*"):
			priority[encoding] = q
		else:
			starPriority = q
	if(starPriority):
		for i in allEncodings:
			if(i not in seenEncodings):
				priority[i] = starPriority
	try:
		priority['identity'] = 1
		if pflag == 1:
			priority.pop(encoding, None)
		return max(priority, key=priority.get)

	except ValueError:
		return None

	takes in accept-encoding header value(str) and returns 
	which encoding to use according to q priority
	
takes in accept-encoding header value(str) and returns
which encoding to use according to q priority
takes in accept - encoding header value ( str ) and returns which encoding to use according to q priority
def prioritizeEncoding(acceptVal):
	if(acceptVal == ""):
		return "identity"
	allEncodings = [
		"br",
		"compress",
		"deflate",
		"gzip",
		"exi",
		"pack200-gzip",
		"x-compress",
		"x-gzip",
		"zstd"
	]
	priority=dict()
	tmp = acceptVal.split(',')
	starPriority = 0
	seenEncodings = []
	pflag = 0
	for i in tmp:
		i = i.strip()
		pair = i.split(';')
		encoding = pair[0].strip()
		seenEncodings.append(encoding)
		if len(pair) == 1:
			pair.append("q=1.0")
		q = float(pair[1].split("=")[1].strip())
		if(q == 0.0):
			if(encoding=="identity"):
				pflag = 1
			continue
		if(encoding!="*"):
			priority[encoding] = q
		else:
			starPriority = q
	if(starPriority):
		for i in allEncodings:
			if(i not in seenEncodings):
				priority[i] = starPriority
	try:
		priority['identity'] = 1
		if pflag == 1:
			priority.pop(encoding, None)
		return max(priority, key=priority.get)
	except ValueError:
		return None
def prioritizeEncoding ( acceptVal ) : if ( acceptVal == "" ) : return "identity" allEncodings = [ "br" , "compress" , "deflate" , "gzip" , "exi" , "pack200-gzip" , "x-compress" , "x-gzip" , "zstd" ] priority = dict ( ) tmp = acceptVal . split ( ',' ) starPriority = 0 seenEncodings = [ ] pflag = 0 for i in tmp : i = i . strip ( ) pair = i . split ( ';' ) encoding = pair [ 0 ] . strip ( ) seenEncodings . append ( encoding ) if len ( pair ) == 1 : pair . append ( "q=1.0" ) q = float ( pair [ 1 ] . split ( "=" ) [ 1 ] . strip ( ) ) if ( q == 0.0 ) : if ( encoding == "identity" ) : pflag = 1 continue if ( encoding != "*" ) : priority [ encoding ] = q else : starPriority = q if ( starPriority ) : for i in allEncodings : if ( i not in seenEncodings ) : priority [ i ] = starPriority try : priority [ 'identity' ] = 1 if pflag == 1 : priority . pop ( encoding , None ) return max ( priority , key = priority . get ) except ValueError : return None
takes in accept-encoding header value(str) and returns
which encoding to use according to q priority
takes in accept - encoding header value ( str ) and returns which encoding to use according to q priority
"""
	takes in accept-encoding header value(str) and returns 
	which encoding to use according to q priority
	"""
acceptVal