Apache Mod-Python - Commented: (MODPYTHON-238) req.connection.keepalive should

This is Interesting: Free IT Magazines  
Home > Archive > Apache Mod-Python > July 2007 > Commented: (MODPYTHON-238) req.connection.keepalive should





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Commented: (MODPYTHON-238) req.connection.keepalive should
Graham Dumpleton (JIRA)

2007-07-09, 1:13 am


[ https://issues.apache.org/jira/brow...action_12511033 ]

Graham Dumpleton commented on MODPYTHON-238:
--------------------------------------------

Setting req.chunked to 0 by itself doesn't actually disable chunking. It is all because of some weird code in modules/http/http_protocol.c which gets called on first call to write() and which starts with:

if ((r->connection->keepalive != AP_CONN_CLOSE)
&& ((r->status == HTTP_NOT_MODIFIED)
|| (r->status == HTTP_NO_CONTENT)
|| r->header_only
|| apr_table_get(r->headers_out, "Content-Length")
|| ap_find_last_token(r->pool,
apr_table_get(r->headers_out,
"Transfer-Encoding"),
"chunked")
|| ((r->proto_num >= HTTP_VERSION(1,1))
&& (r->chunked = 1))) /* THIS CODE IS CORRECT, see above. */
&& r->server->keep_alive
&& (r->server->keep_alive_timeout > 0)
&& ((r->server->keep_alive_max == 0)
|| (r->server->keep_alive_max > r->connection->keepalives))
&& !ap_status_drops_connection(r->status)
&& !wimpy
&& !ap_find_token(r->pool, conn, "close")
&& (!apr_table_get(r->subprocess_env, "nokeepalive")
|| apr_table_get(r->headers_in, "Via"))
&& ((ka_sent = ap_find_token(r->pool, conn, "keep-alive"))
|| (r->proto_num >= HTTP_VERSION(1,1)))) {

Thus, if r->connection->keepalive is not AP_CONN_CLOSE, it will overwrite r->chunked as a side affect of the if condition.

Thus, only way to turn off chunking is to set connection to close as well as turn chunking to off. Ie.,

r->connection->keepalive = apache.AP_CONN_CLOSE
r->chunked = 0

If you don't care whether chunking is used or not and just want to ensure connection is closed, would instead use:

r->connection->keepalive = apache.AP_CONN_CLOSE

or (I think):

r->subprocess_env['keepalive'] = "0"

or:

r->headers_out['Connection'] = 'Close'

All up, all I am doing is making writable things at C API level that module writer may want to change. How they are used is governed by Apache and not changing that. Frankly, some of this stuff is real black magic. :-(


> req.connection.keepalive should be writable
> -------------------------------------------
>
> Key: MODPYTHON-238
> URL: https://issues.apache.org/jira/browse/MODPYTHON-238
> Project: mod_python
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.3.1
> Reporter: Graham Dumpleton
> Priority: Minor
>
> The attribute req.connection.keepalive should be writable. This would allow handlers to use:
> req.connection.keepalive = apache.AP_CONN_CLOSE
> Doing this before any data is written has the effect of disabling keepalive and also turning off chunked encoding for response content when no content length has been supplied.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com