def handleResponse(self, response): if self.content_is_gzip: c_f = StringIO(response) response = gzip.GzipFile(fileobj=c_f).read() self.cachetemp['response'] = response self.factory.cache[self.factory.url] = self.cachetemp HTTPPageGetter.handleResponse(self, response)
def handleHeader(self, key, value): key = key.lower() if key == 'date' or key == 'last-modified': self.cachetemp[key] = value if key == 'content-encoding' and value == 'gzip': self.content_is_gzip = True HTTPPageGetter.handleHeader(self, key, value)
def lineReceived(self, line): if self.firstLine: return HTTPPageGetter.lineReceived(self, line) if not self.inBody: if line: # still a header line return HTTPPageGetter.lineReceived(self, line) self.inBody = True # json from couch uses \n delims. self.delimiter = '\n' self.factory.deferred.callback(self.transport.loseConnection) return self.handleChange(json.loads(line))
def dataReceived(self, data): try: self.detectedDelimiter except AttributeError: if data.find("\r\n") >= 0: self.detectedDelimiter = 1 else: self.detectedDelimiter = 1 self.delimiter = "\n" return HTTPPageGetter.dataReceived(self, data)
def handleStatus(self, version, status, message): HTTPPageGetter.handleStatus(self, version, status, message)
def connectionMade(self): log.debug(u'Stream Connected') self.__buffer = '' self.factory.stream_connected() HTTPPageGetter.connectionMade(self)
def connectionMade(self): HTTPPageGetter.connectionMade(self) ClientMixin.connectionMade(self)
def handleHeader(self, key, value): """ hook method and save headers in their right order """ HTTPPageGetter.handleHeader(self, key, value) self.factory.orderedHeaders.append(Header(key.decode("utf-8"), value.decode("utf-8")))