[Twisted-Python] Pausing the transport in http.HTTPChannel.lineReceived after all headers are received
Adi Roiban
adi at roiban.ro
Thu Mar 19 09:26:56 MDT 2015
Hi,
My usecase is this:
When all headers of an HTTP request are received I want to ask a
remote service if the
request should be accepted and what to do with it.
Before I got the response for the remote service, I don't want to
receive/read HTTP data.
The response is returned via an deferred.
The HTTP data might be a 10G file which might be rejected.. for
example due to quota limits.
Here is a gist with a short example and my quick and dirty fix:
https://gist.github.com/adiroiban/621efeab47662a04cb20
------
Do you think this is a valid use case and that someone would be
willing to review a patch to add such a feature?
-------
I first went on a wrong path as I was calling
self.transport.pauseProducing() instead of self.pauseProducing() but
while reading the code I found this:
In http.HTTPChannel self.transport.producerPaused is confusing as it
is always False.. and looking at the code from internet/abstract.py I
can see that it is not touched by pauseProducing() ... how should
producerPaused be used?
Is this a bug or a feature? Is there a ticket for it?
I saw that when you return a non-zero value from lineReceived() it
will stop processing the remaining data but I could not find the
documentation for this behaviour.
Should I continue searching for the documentation ? or file a ticket?
Thanks!
--
Adi Roiban
More information about the Twisted-Python
mailing list