Sorry about the formatting, it was a quick refactor of the monkey patch I ended up using to get it working for me to show the nature of the problem. While I tested the original monkey patch quite a bit, in my haste I didn't test the monkey-patch-less version. I can attach a new patch if you like, but you have probably already fixed it locally if you were able to recreate the problem and prove this fixes it?
While I agree that making this patch only active on 2.6 is probably a good idea, I just wanted to stress that this isn't some weird hack to make python 2.6 work. Calling self.close() if the method is HEAD is the right thing to do. Or at least, thats what python 2.7 and later do - this patch it is essentially a backport of the behaviour found on all later pythons.
What is the preferred way to hide something like this from python 2.7 and later in libcloud?