Ejemplo n.º 1
0
    def dataReceived(self, bytes):
        """
        Receive some data and extend the timeout period of this request.

        :param bytes: A string of indeterminate length.
        :type bytes: str
        """
        HTTP11ClientProtocol.dataReceived(self, bytes)
        if self._timeoutCall and self._timeoutCall.active():
            self._timeoutCall.reset(self._timeout)
Ejemplo n.º 2
0
    def dataReceived(self, bytes):
        """
        Receive some data and extend the timeout period of this request.

        :param bytes: A string of indeterminate length.
        :type bytes: str
        """
        HTTP11ClientProtocol.dataReceived(self, bytes)
        if self._timeoutCall and self._timeoutCall.active():
            self._timeoutCall.reset(self._timeout)
Ejemplo n.º 3
0
    def __init__(self, quiescentCallback, timeout):
        """
        Initialize the protocol.

        :param quiescentCallback:
        :type quiescentCallback: callable
        :param timeout: A timeout, in seconds, for requests made by this
                        protocol.
        :type timeout: float
        """
        HTTP11ClientProtocol.__init__(self, quiescentCallback)
        self._timeout = timeout
        self._timeoutCall = None
Ejemplo n.º 4
0
    def __init__(self, quiescentCallback, timeout):
        """
        Initialize the protocol.

        :param quiescentCallback:
        :type quiescentCallback: callable
        :param timeout: A timeout, in seconds, for requests made by this
                        protocol.
        :type timeout: float
        """
        HTTP11ClientProtocol.__init__(self, quiescentCallback)
        self._timeout = timeout
        self._timeoutCall = None
Ejemplo n.º 5
0
    def request(self, request):
        """
        Issue request over self.transport and return a Deferred which
        will fire with a Response instance or an error.

        :param request: The object defining the parameters of the request to
                        issue.
        :type request: twisted.web._newclient.Request

        :return: A deferred which fires after the request has finished.
        :rtype: Deferred
        """
        d = HTTP11ClientProtocol.request(self, request)
        if self._timeout:
            self._last_buffer_len = 0
            timeoutCall = reactor.callLater(
                self._timeout, self._doTimeout, request)
            self._timeoutCall = timeoutCall
        return d
Ejemplo n.º 6
0
    def request(self, request):
        """
        Issue request over self.transport and return a Deferred which
        will fire with a Response instance or an error.

        :param request: The object defining the parameters of the request to
                        issue.
        :type request: twisted.web._newclient.Request

        :return: A deferred which fires after the request has finished.
        :rtype: Deferred
        """
        d = HTTP11ClientProtocol.request(self, request)
        if self._timeout:
            self._last_buffer_len = 0
            timeoutCall = reactor.callLater(self._timeout, self._doTimeout,
                                            request)
            self._timeoutCall = timeoutCall
        return d
Ejemplo n.º 7
0
	def request(self, request):
		if self.timeout:
			self.setTimeout(self.timeout)

		def _cb(result, self=self):
			# Reset timeouts
			self.setTimeout(None)

			return result

		def _eb(result, self=self):
			# Reset timeouts
			self.setTimeout(None)

			return result

		deferred = HTTP11ClientProtocol.request(self, request)
		deferred.addCallbacks(_cb, _eb)

		# Success
		return deferred
Ejemplo n.º 8
0
 def connectionLost(self, reason):
     self._cancelTimeout()
     return HTTP11ClientProtocol.connectionLost(self, reason)
Ejemplo n.º 9
0
 def _finishResponse(self, rest):
     """
     Cancel the timeout when finished receiving the response.
     """
     self._cancelTimeout()
     HTTP11ClientProtocol._finishResponse(self, rest)
Ejemplo n.º 10
0
 def connectionLost(self, reason):
     self._cancelTimeout()
     return HTTP11ClientProtocol.connectionLost(self, reason)
Ejemplo n.º 11
0
 def _finishResponse(self, rest):
     """
     Cancel the timeout when finished receiving the response.
     """
     self._cancelTimeout()
     HTTP11ClientProtocol._finishResponse(self, rest)