old_contents: from . import CookieParser, CookieDict
  
  def parse_cookies(httplib_headers):
      cookies = [
          CookieParser.parse_set_cookie_value(
              header[1]
          ) for header in httplib_headers if header[0].lower() == 'set-cookie'
      ]
      return cookies
  
new_contents: from . import CookieParser, CookieDict
  
  def parse_cookies(httplib_set_cookie_headers):
      cookies = []
      for header in httplib_set_cookie_headers:
          header = header.strip()
          name, value = header.split(' ', 1)
          value = value.strip()
          cookie = CookieParser.parse_set_cookie_value(value)
          cookies.append(cookie)
      return cookies
  
  def parse_response_cookies(httplib_response):
      # RFC 2616 specifies that multiple headers can be combined into
      # a single header by joining their values with commas
      # (http://stackoverflow.com/questions/2454494/urllib2-multiple-set-cookie-headers-in-response).
      # However, Set-Cookie headers simply cannot be combined in that way
      # as they have commas in dates and also there is no standard
      # way of quoting cookie values, which may also have commas.
      # Therefore the correct way of accessing Set-Cookie headers
      # is via httplib_response.msg.getallmatchingheaders() call.
      # http://mail.python.org/pipermail/python-bugs-list/2007-March/037618.html
      # Also:
      # http://stackoverflow.com/questions/1649401/how-to-handle-multiple-set-cookie-header-in-http-response
      headers = httplib_response.msg.getallmatchingheaders('set-cookie')
      headers.extend(httplib_response.msg.getallmatchingheaders('set-cookie2'))
      return parse_cookies(headers)
  
subject: Change API for parsing httplib cookies