Skip to content
Myr

implement changes after code review

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by dbairaktaris1 · committed by dbairaktaris1 · parent 1988d9c · Browse files · 2 files+5 added−20 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−20 removed

  • tests:+0 added−8 removed
  • other:+5 added−12 removed

2 files+5 added−20 removed

modified:requests/utils.py+5 added-12 removed
451 unmodified lines
452 :param header: string453 :return: tuple containing content type and dictionary of454 parameters455 """456 if not header:457 return None458 # append delimiter on end to ensure at least two elements when split by ';'459 header += ';'460 # split content type's main value from params461 tokens = header.split(';', 1)462 content_type_index = 0463 params_index = 1456465 content_type = tokens[content_type_index].strip()466 params = tokens[params_index]467 params_dict = dict()457 tokens = header.split(';')458 content_type, params = tokens[0].strip(), tokens[1:]459 params_dict = {} # Using dict is actually slower than a dictionary literal. Weird but tru460469 for param in params.split(';'):461 for param in params:462 if param and not param.isspace():463 param = param.strip()464 key, value = param, True465 if '=' in param:
1 unmodified line
467 key, value = param_tokens[0], param_tokens[1]468 params_dict[key] = value469 return content_type, params_dict470471472def get_encoding_from_headers(headers):473 """Returns encodings from given HTTP Header Dict.474475 :param headers: dictionary to extract encoding from.
495 unmodified lines
modified:tests/test_utils.py-8 removed
471 unmodified lines
472473@pytest.mark.parametrize(474 'value, expected', (475 (476 None,477 None478 ),479(480 '',481 None482 ),483 (476 'application/xml',477 ('application/xml', dict())478 ),479 (
265 unmodified lines