import collections


def _parse_http_header(header_str):
    """
        Converts the http response and request headers to a dictionary form.
        The convert_http_str_ti_response_obj and convert_http_str_to_request_obj methods use this method for parsing
        the header part of a request or response.

        :param header_str: The header as a string
        :return: The header as a dictionary
    """
    return_headers = collections.OrderedDict()
    headers = header_str.split('\n')
    for header in headers:
        key_value_pair = header.split(': ', 1)
        if len(key_value_pair) is 2:
            return_headers[key_value_pair[0]] = key_value_pair[1]
    return return_headers