Fixes a socket error.

I assume you mean this fixes the unclosed socket warning in python 3? Is there a specific reason why this `hasattr` check is here? It seems like the `http` attr is always set?