def _parse_request(header_data, ignore_bad_cookies=False):
 cookies_dict = {}
 for line in Definitions.EOL.split(header_data.strip()):
  matches = Definitions.COOKIE_RE.finditer(line)
  matches = [item for item in matches]
  for match in matches:
   invalid = match.group('invalid')
   if invalid:
    if (not ignore_bad_cookies):
     raise InvalidCookieError(data=invalid)
    _report_invalid_cookie(invalid)
    continue
   name = match.group('name')
   values = cookies_dict.get(name)
   value = match.group('value').strip('"')
   if values:
    values.append(value)
   else:
    cookies_dict[name] = [value]
  if (not matches):
   if (not ignore_bad_cookies):
    raise InvalidCookieError(data=line)
   _report_invalid_cookie(line)
 return cookies_dict

def _parse_request ( header_data , ignore_bad_cookies = False ) : cookies_dict = { } for line in Definitions . EOL . split ( header_data . strip ( ) ) : matches = Definitions . COOKIE_RE . finditer ( line ) matches = [ item for item in matches ] for match in matches : invalid = match . group ( 'invalid' ) if invalid : if ( not ignore_bad_cookies ) : raise InvalidCookieError ( data = invalid ) _report_invalid_cookie ( invalid ) continue name = match . group ( 'name' ) values = cookies_dict . get ( name ) value = match . group ( 'value' ) . strip ( '"' ) if values : values . append ( value ) else : cookies_dict [ name ] = [ value ] if ( not matches ) : if ( not ignore_bad_cookies ) : raise InvalidCookieError ( data = line ) _report_invalid_cookie ( line ) return cookies_dict
turn one or more lines of cookie: header data into a dict mapping cookie names to cookie values .