httplib CannotSendRequest error in WSGI

后端 未结 2 936
醉话见心
醉话见心 2020-12-01 18:42

I\'ve used two different python oauth libraries with Django to authenticate with twitter. The setup is on apache with WSGI. When I restart the server everything works grea

相关标签:
2条回答
  • 2020-12-01 18:50

    This exception is raised when you reuse httplib.HTTP object for new request while you havn't called its getresponse() method for previous request. Probably there was some other error before this one that left connection in broken state. The simplest reliable way to fix the problem is creating new connection for each request, not reusing it. Sure, it will be a bit slower, but I think it's not an issue having you are running application in single process and single thread.

    0 讨论(0)
  • 2020-12-01 19:02

    Also check your Python version. I had a similar situation after updating to Py-2.7 from Py-2.6. In Py-2.6 everything worked without any problems. Py-2.7 httplib uses HTTP/1.1 by default which made the server did not send back the Connection: close option in the respond, therefore the connection handling was broken. In my case this worked with HTTP/1.0 though.

    0 讨论(0)
提交回复
热议问题