Scrapy, a fast high-level web crawling & scraping framework for Python.
remove obsolete monkey patch for twisted 2.5
Daniel Grana8ecd16b5e33a
diff --git a/scrapy/xlib/patches.py b/scrapy/xlib/patches.pyindex a9a0890ce..6c9c20d96 100644--- a/scrapy/xlib/patches.py+++ b/scrapy/xlib/patches.py@@ -6,39 +6,8 @@ import twisteddef apply_patches():if twisted.__version__ < '8.0.0':- patch_HTTPPageGetter_handleResponse()add_missing_blockingCallFromThread()--# bugfix not present in twisted 2.5 for handling empty response of HEAD requests-def patch_HTTPPageGetter_handleResponse():- from twisted.web.client import PartialDownloadError, HTTPPageGetter- from twisted.python import failure- from twisted.web import error-- def _handleResponse(self, response):- if self.quietLoss:- return- if self.failed:- self.factory.noPage(- failure.Failure(- error.Error(- self.status, self.message, response)))- if self.factory.method.upper() == 'HEAD':- # Callback with empty string, since there is never a response- # body for HEAD requests.- self.factory.page('')- elif self.length != None and self.length != 0:- self.factory.noPage(failure.Failure(- PartialDownloadError(self.status, self.message, response)))- else:- self.factory.page(response)- # server might be stupid and not close connection. admittedly- # the fact we do only one request per connection is also- # stupid...- self.transport.loseConnection()- setattr(HTTPPageGetter, 'handleResponse', _handleResponse)-# This function comes bundled with Twisted 8.x and abovedef add_missing_blockingCallFromThread():import Queue