|
|
Choosing A Webhost: |
[patch] proper backcompat $r->send_http_header: msg#00074apache.mod-perl.devel
Currently, $r->send_http_header can't be called before the response stage, so the 1.0 code won't run out of the box. This is an attempt to solve that problem. I haven't committed it, because I'm not sure whether the following assumption will stand: - wb->header_parse = MpDirPARSE_HEADERS(dcfg) ? 1 : 0; + wb->header_parse = (!r->content_type && MpDirPARSE_HEADERS(dcfg)) ? 1 : What I say is that if the content_type is already set, we don't need to parse headers. Does it make sense? Or could there be some subtle cases where some pre-response handler will set the content-type, but the response handler will be a cgi script that will send a different content-type header? I think that this is quite possible. In that case I'm not sure how to handle this. We need a way to tell the response stage to skip headers parsing if send_http_header was called. Index: Changes =================================================================== RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.127 diff -u -r1.127 Changes --- Changes 19 Feb 2003 00:32:45 -0000 1.127 +++ Changes 19 Feb 2003 03:37:17 -0000 @@ -10,6 +10,12 @@ =item 1.99_09-dev +move $r->send_http_header implementation to Apache::compat. adjust +modperl_response_init() to parse headers only if told to and +$r->content_type wasn't set already. This allows the 1.0 code to run +unchanged if $r->send_http_header is called before the response +change. + add Apache::Bundle2 [Stas] Apache::Reload now supports the PerlPreConnectionHandler invocation Index: lib/Apache/compat.pm =================================================================== RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v retrieving revision 1.79 diff -u -r1.79 compat.pm --- lib/Apache/compat.pm 17 Feb 2003 09:47:31 -0000 1.79 +++ lib/Apache/compat.pm 19 Feb 2003 03:37:17 -0000 @@ -154,6 +154,11 @@ return Apache::current_callback(); } +sub send_http_header { + my ($r, $type) = @_; + $r->content_type($type) if defined $type; +} + #to support $r->server_root_relative *server_root_relative = \&Apache::server_root_relative; Index: src/modules/perl/mod_perl.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v retrieving revision 1.151 diff -u -r1.151 mod_perl.c --- src/modules/perl/mod_perl.c 4 Feb 2003 06:52:15 -0000 1.151 +++ src/modules/perl/mod_perl.c 19 Feb 2003 03:37:17 -0000 @@ -733,7 +733,7 @@ wb->pool = r->pool; wb->filters = &r->output_filters; wb->outcnt = 0; - wb->header_parse = MpDirPARSE_HEADERS(dcfg) ? 1 : 0; + wb->header_parse = (!r->content_type && MpDirPARSE_HEADERS(dcfg)) ? 1 : 0; wb->r = r; } Index: t/response/TestCompat/apache.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestCompat/apache.pm,v retrieving revision 1.4 diff -u -r1.4 apache.pm --- t/response/TestCompat/apache.pm 17 Feb 2003 09:03:17 -0000 1.4 +++ t/response/TestCompat/apache.pm 19 Feb 2003 03:37:17 -0000 @@ -55,3 +55,6 @@ 1; +__END__ +# so we can test whether send_httpd_header() works fine +PerlOptions +ParseHeaders Index: xs/Apache/Response/Apache__Response.h =================================================================== RCS file: /home/cvs/modperl-2.0/xs/Apache/Response/Apache__Response.h,v retrieving revision 1.8 diff -u -r1.8 Apache__Response.h --- xs/Apache/Response/Apache__Response.h 17 Jan 2003 02:26:31 -0000 1.8 +++ xs/Apache/Response/Apache__Response.h 19 Feb 2003 03:37:17 -0000 @@ -13,28 +13,6 @@ rcfg->wbucket->header_parse = 0; \ } -/* XXX: should only be part of Apache::compat */ -static MP_INLINE void -mpxs_Apache__RequestRec_send_http_header(pTHX_ request_rec *r, - const char *type) -{ - MP_dRCFG; - - if (type) { - ap_set_content_type(r, apr_pstrdup(r->pool, type)); - } - - if (rcfg->wbucket) { - /* turn off PerlOptions +ParseHeaders */ - rcfg->wbucket->header_parse = 0; - } - else { - /* the response is not initialized yet */ - Perl_croak(aTHX_ "send_http_header() can't be called before " - "the response phase"); - } -} - static MP_INLINE void mpxs_Apache__RequestRec_set_last_modified(request_rec *r, apr_time_t mtime) { Index: xs/maps/modperl_functions.map =================================================================== RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v retrieving revision 1.53 diff -u -r1.53 modperl_functions.map --- xs/maps/modperl_functions.map 17 Feb 2003 09:03:17 -0000 1.53 +++ xs/maps/modperl_functions.map 19 Feb 2003 03:37:17 -0000 @@ -56,7 +56,6 @@ MODULE=Apache::Response PACKAGE=Apache::RequestRec DEFINE_send_cgi_header | | request_rec *:r, SV *:buffer - mpxs_Apache__RequestRec_send_http_header | | r, type=NULL mpxs_Apache__RequestRec_set_last_modified | | r, mtime=0 Index: xs/tables/current/ModPerl/FunctionTable.pm =================================================================== RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v retrieving revision 1.104 diff -u -r1.104 FunctionTable.pm --- xs/tables/current/ModPerl/FunctionTable.pm 31 Jan 2003 04:20:20 -0000 1.104 +++ xs/tables/current/ModPerl/FunctionTable.pm 19 Feb 2003 03:37:17 -0000 @@ -5529,24 +5529,6 @@ ] }, { - 'return_type' => '', - 'name' => 'mpxs_Apache__RequestRec_send_http_header', - 'args' => [ - { - 'type' => 'PerlInterpreter *', - 'name' => 'my_perl' - }, - { - 'type' => 'request_rec *', - 'name' => 'r' - }, - { - 'type' => 'const char *', - 'name' => 'type' - } - ] - }, - { 'return_type' => 'int', 'name' => 'mpxs_Apache__RequestRec_OPEN', 'args' => [ __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:stas@xxxxxxxxxx http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: auth_type issues, Geoffrey Young |
|---|---|
| Next by Date: | Re: Problem Building 1.99_08 on OpenBSD, Carl Brewer |
| Previous by Thread: | Re: cvs commit: modperl-2.0/xs/maps modperl_functions.map, Stas Bekman |
| Next by Thread: | Re: [patch] proper backcompat $r->send_http_header, Geoffrey Young |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |