masperro / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

Multiple set-cookie headers not retrieved (only one, the last one) #90

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Communicate with a server that returns multiple set-cookie headers
2. Notice that only one, that last returned from info.getheaders() is 
retrieved

What is the expected output? What do you see instead?
Should allow for multiple set-cookie headers, ideally returned in the order 
retrieved by info.getheaders()

What version of the product are you using? On what operating system?
0.6.0 on WinXP

Please provide any additional information below.
Here's example code, Response.__init__ that does this. However, instead of 
returning a string, the returned set-cookie headers are a list.

  def __init__(self, info):
    # info is either an email.message or 
    # an httplib.HTTPResponse object.
    if isinstance(info, http.client.HTTPResponse):
      for key, value in info.getheaders():
        _key = key.lower()
        if _key == 'set-cookie':
          if _key in self: self[_key].append(value)
          else: self[_key] = [value]
        else:
          self[_key] = value
      self.status = info.status
      self['status'] = str(self.status)
      self.reason = info.reason
      self.version = info.version
    elif isinstance(info, email.message.Message):
      for key, value in list(info.items()): 
        self[key.lower()] = value 
      self.status = int(self['status'])
    else:
      for key, value in info.items(): 
        self[key.lower()] = value 
      self.status = int(self.get('status', self.status))

Original issue reported on code.google.com by bidl...@gmail.com on 2 Feb 2010 at 3:40

GoogleCodeExporter commented 8 years ago
Cookie handling is a known weak point.

Original comment by joe.gregorio@gmail.com on 14 May 2010 at 4:12