'Parse HTTP header data into Python structures. (Core)'

def process_headers(self):

    headers = self.headers
    for (name, value) in self.header_list:
        name = name.title()
        value = value.strip()
        if ('=?' in value):
            dict.__setitem__(headers, name, httputil.decode_TEXT(value))
        else:
            dict.__setitem__(headers, name, value)
        if (name == 'Cookie'):
            try:
                self.cookie.load(value)
            except CookieError:
                msg = ('Illegal    cookie    name    %s' % value.split('=')[0])
                raise cherrypy.HTTPError(400, msg)
    if (not dict.__contains__(headers, 'Host')):
        if (self.protocol >= (1, 1)):
            msg = "HTTP/1.1    requires    a    'Host'    request    header."
            raise cherrypy.HTTPError(400, msg)
    host = dict.get(headers, 'Host')
    if (not host):
        host = (self.local.name or self.local.ip)
    self.base = ('%s://%s' % (self.scheme, host))
