[Httplib2-discuss] =?WINDOWS-1252?Q?Bug_#1462092:_Follow-up_=96_Erro?= =?WINDOWS-1252?Q?r_processing
Status: Beta
Brought to you by:
jcgregorio
From: Thomas B. <t.b...@gm...> - 2006-04-03 07:56:29
|
My patch has been incorporated but the HOP_BY_HOP.extends() part of the previous code has been kept as-is, which means HOP_BY_HOP is modified at each request. As an example, I've added "print httplib2.HOP_BY_HOP" at the beggining and end of httplib2test.HttpPrivateTest.testEnd2End as well as between each test in the method. This is the result: ['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailers', 'transfer-encoding', 'upgrade'] ['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailers', 'transfer-encoding', 'upgrade', ''] ['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailers', 'transfer-encoding', 'upgrade', '', 'content-type'] ['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailers', 'transfer-encoding', 'upgrade', '', 'content-type', ''] ['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailers', 'transfer-encoding', 'upgrade', '', 'content-type', '', 'content-type'] As you can see, the global variable HOP_BY_HOP is extended between each call to httplib2._get_end2end_headers. This means that if I get a first response with: Connection: foo, bar then a second with: Connection: bar Foo: this should be end-to-end the "foo" header in the second response will be considered hop-by-hop. If you don't like my: if headers.has_key('connection'): hopbyhop =3D HOP_BY_HOP + [x.strip() for x in response.get('connection', '').split(',')] else: hopbyhop =3D HOP_BY_HOP you can just do: hopbyhop =3D list(HOP_BY_HOP) hopbyhop.extend([x.strip() for x in response.get('connection', '').split(',')]) By using "list(HOP_BY_HOP)", we're making a copy of HOP_BY_HOP that we can then extend without modifying the global variable. -- Thomas Broyer |