stas 2003/03/13 21:36:48
Modified: xs/Apache/Response Apache__Response.h
. Changes
Added: t/response/TestApache send_cgi_header.pm
t/apache send_cgi_header.t
Log:
send_cgi_header now turns the header parsing off and can send any data
attached after the response headers as a response body
+ tests
Revision Changes Path
1.1 modperl-2.0/t/response/TestApache/send_cgi_header.pm
Index: send_cgi_header.pm
===================================================================
package TestApache::send_cgi_header;
use strict;
use warnings FATAL => 'all';
use Apache::Response ();
use Apache::Const -compile => qw(OK);
sub handler {
my $r = shift;
my $response = <<EOF;
Content-type: text/plain
X-Foo: X-Bar
Set-Cookie: Bad Programmer, No cookie!
This not the end of the world
EOF
# bah, we can send the header and the response here
# don't tell anybody
$r->send_cgi_header($response);
Apache::OK;
}
1;
__END__
# this should work regardless whether parse headers is on or off
PerlOptions -ParseHeaders
1.1 modperl-2.0/t/apache/send_cgi_header.t
Index: send_cgi_header.t
===================================================================
use strict;
use warnings FATAL => 'all';
use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest;
plan tests => 3;
my $location = "/TestApache::send_cgi_header";
my $res = GET $location;
ok t_cmp('X-Bar',
$res->header('X-Foo'),
"header test");
ok t_cmp('Bad Programmer, No cookie!',
$res->header('Set-Cookie'),
"header test2");
ok t_cmp("This not the end of the world\n",
$res->content,
"body test");
1.10 +6 -4 modperl-2.0/xs/Apache/Response/Apache__Response.h
Index: Apache__Response.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/Apache/Response/Apache__Response.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Apache__Response.h 19 Feb 2003 23:55:23 -0000 1.9
+++ Apache__Response.h 14 Mar 2003 05:36:48 -0000 1.10
@@ -1,6 +1,3 @@
-/*
- * XXX: should do something useful if we end up with any bodytext
- */
/* XXX: this should probably named $r->cgi_header_parse
* and send_cgi_header an alias in Apache::compat
*/
@@ -9,8 +6,13 @@
MP_dRCFG; \
STRLEN len; \
const char *bodytext; \
+ MP_CGI_HEADER_PARSER_OFF(rcfg); \
modperl_cgi_header_parse(r, SvPV(sv,len), &bodytext); \
- rcfg->wbucket->header_parse = 0; \
+ if (bodytext) {\
+ MP_CHECK_WBUCKET_INIT("$r->send_cgi_header"); \
+ len -= (bodytext - SvPVX(sv)); \
+ modperl_wbucket_write(aTHX_ rcfg->wbucket, bodytext, &len); \
+ } \
}
static MP_INLINE void
1.150 +3 -0 modperl-2.0/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -r1.149 -r1.150
--- Changes 14 Mar 2003 05:33:19 -0000 1.149
+++ Changes 14 Mar 2003 05:36:48 -0000 1.150
@@ -10,6 +10,9 @@
=item 1.99_09-dev
+send_cgi_header now turns the header parsing off and can send any data
+attached after the response headers as a response body. [Stas]
+
move the check that print/printf/puts/write/etc are called in the
response phase into the functions themselves so 1) we can print a more
useful error message 2) this check is not always needed in