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

Function _parse_http_header

thirdparty/bottle/bottle.py:3406–3436  ·  view source on GitHub ↗

Parses a typical multi-valued and parametrised HTTP header (e.g. Accept headers) and returns a list of values and parameters. For non-standard or broken input, this implementation may return partial results. :param h: A header string (e.g. ``text/html,text/plain;q=0.9,*/*;q=0.8``) :

(h)

Source from the content-addressed store, hash-verified

3404_hsplit = re.compile('(?:(?:"((?:[^"\\\\]|\\\\.)*)")|([^;,=]+))([;,=]?)').findall
3405
3406def _parse_http_header(h):
3407 """ Parses a typical multi-valued and parametrised HTTP header (e.g. Accept headers) and returns a list of values
3408 and parameters. For non-standard or broken input, this implementation may return partial results.
3409 :param h: A header string (e.g. ``text/html,text/plain;q=0.9,*/*;q=0.8``)
3410 :return: List of (value, params) tuples. The second element is a (possibly empty) dict.
3411 """
3412 values = []
3413 if '"' not in h: # INFO: Fast path without regexp (~2x faster)
3414 for value in h.split(','):
3415 parts = value.split(';')
3416 values.append((parts[0].strip(), {}))
3417 for attr in parts[1:]:
3418 name, value = attr.split('=', 1)
3419 values[-1][1][name.strip()] = value.strip()
3420 else:
3421 lop, key, attrs = ',', None, {}
3422 for quoted, plain, tok in _hsplit(h):
3423 value = plain.strip() if plain else quoted.replace('\\"', '"')
3424 if lop == ',':
3425 attrs = {}
3426 values.append((value, attrs))
3427 elif lop == ';':
3428 if tok == '=':
3429 key = value
3430 else:
3431 attrs[value] = ''
3432 elif lop == '=' and key:
3433 attrs[key] = value
3434 key = None
3435 lop = tok
3436 return values
3437
3438
3439def _parse_qsl(qs):

Callers

nothing calls this directly

Calls 2

appendMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…