Add HTTPHeaders.copy() #519

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@simpkins

Update HTTPHeaders to provide its own implementation of copy() that
returns a new HTTPHeaders object. Previously calling copy() used the
underlying dict method, and returned a plain dict.

Add HTTPHeaders.copy()
Update HTTPHeaders to provide its own implementation of copy() that
returns a new HTTPHeaders object.  Previously calling copy() used the
underlying dict method, and returned a plain dict.
@bdarnell

This comment has been minimized.

Show comment Hide comment
@bdarnell

bdarnell May 26, 2012

Owner

I added "copy constructor" behavior to HTTPHeaders in 2f35821#diff-0
(which hasn't yet made it into any release), so I think all that's needed is to make copy() return HTTPHeaders(self) instead of dict(self)

Owner

bdarnell commented May 26, 2012

I added "copy constructor" behavior to HTTPHeaders in 2f35821#diff-0
(which hasn't yet made it into any release), so I think all that's needed is to make copy() return HTTPHeaders(self) instead of dict(self)

@bdarnell bdarnell closed this in f41306d May 26, 2012

@helderm

This comment has been minimized.

Show comment Hide comment
@helderm

helderm Apr 17, 2015

Is this really closed? I'm still seeing this error on 4.1.

In [0]: from tornado.httputil import HTTPHeaders
In [1]: h = HTTPHeaders()
In [2]: h.add('Set-Cookie', 'A=1')
In [3]: h.add('Set-Cookie', 'B=2')
In [4]: h.get_list('Set-Cookie')
Out[5]: ['A=1', 'B=2']
In [6]: from copy import deepcopy
In [7]: hc = deepcopy(h)
In [8]: hc.get_list('Set-Cookie')
Out[9]: ['A=1,B=2']

helderm commented Apr 17, 2015

Is this really closed? I'm still seeing this error on 4.1.

In [0]: from tornado.httputil import HTTPHeaders
In [1]: h = HTTPHeaders()
In [2]: h.add('Set-Cookie', 'A=1')
In [3]: h.add('Set-Cookie', 'B=2')
In [4]: h.get_list('Set-Cookie')
Out[5]: ['A=1', 'B=2']
In [6]: from copy import deepcopy
In [7]: hc = deepcopy(h)
In [8]: hc.get_list('Set-Cookie')
Out[9]: ['A=1,B=2']
@bdarnell

This comment has been minimized.

Show comment Hide comment
@bdarnell

bdarnell Apr 17, 2015

Owner

This issue is about the method HTTPHeaders.copy(), which overrides the default dict.copy(). The copy module and its functions copy.copy() and copy.deepcopy() are a separate matter. Feel free to open new issues for problems related to the copy module.

Owner

bdarnell commented Apr 17, 2015

This issue is about the method HTTPHeaders.copy(), which overrides the default dict.copy(). The copy module and its functions copy.copy() and copy.deepcopy() are a separate matter. Feel free to open new issues for problems related to the copy module.

@bdarnell

This comment has been minimized.

Show comment Hide comment
@bdarnell

bdarnell Apr 19, 2015

Owner

FYI I've just fixed the copy.copy issue: 674d7eb

Owner

bdarnell commented Apr 19, 2015

FYI I've just fixed the copy.copy issue: 674d7eb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment