How to fix httplib.BadStatusLine exception?
URL = "MY HTTP REQUEST URL" XML = "<port>0</port>" parameter = urllib.urlencode({'XML': XML}) response = urllib.urlopen(URL, parameter) print response.read() IOError: ('http protocol error', 0, 'got a bad status line', None) I am trying to send XML to a server and get back XML. Is there any way to fix / ignore this exception? I know that the status line is empty which is raising this error. Try to have a look what your server actually returns! It probably isn't a valid HTTP response. You could use something like this to send a raw http request to the server: from socket import socket host =