On Thu, May 7, 2009 at 2:05 PM, Michael Toop <micha...@voxtelecom.co.za> wrote:
> Hi,
>
>  We are struggling to close a TCP connection using web
> resource.Resource (the TR69 SOAP spec. mandates that we close the connection
> when we are done).
>
>  Our site is served in a TCP reactor & uses the NOT_DONE_YET variable in the
> def render_POST method.  We close the render_POST with a
> request.write('data') & a request.finish() but the connection stays open,
> stub code below.
>
>  We are not sure if it is the fact that we are using chunked encoding or if
> this is a bug?
>
>  Please assist.
>
> Warm Regards,
>
> Michael Toop
>
> def render_POST(self,request):
>    ...do stuff
>   d = getSoapText(request)
>   d.addCallback(request.write)
>   d.addCallback(request.close())
>   return server.NOT_DONE_YET
>

I'm guessing it was a typo above and should be something like:

  d.addCallback(lambda ign: request.finish())

Also, I don't think request.finish necessarily entails closing the
connection as this depends upon whether or the channel is persistent
via keep-alive.

I think the rules for connection persistence in twisted.web are:

HTTP 1.0:
           non-persistent
HTTP 1.1 and "Connection: close" in request headers:          non-persistent
HTTP 1.1 and "Connection: close" NOT in request headers:   persistent

-Drew

_______________________________________________
Twisted-web mailing list
Twisted-web@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to