hi all...

I don't know how folks have lived without $r->as_string for as long as they have, but I couldn't, so here's a patch. the only thing that seemed strange as the addition of sv_str_header in RequestUtil.h, but I didn't see another place for generic utility functions like that and apr_table_do is rather funky.

lemme know if I have to send it as an attachment (or just a +1 and I'll commit :)

the only

--Geoff

Index: Changes
===================================================================
RCS file: /home/cvspublic/modperl-2.0/Changes,v
retrieving revision 1.78
diff -u -r1.78 Changes
--- Changes 6 Dec 2002 13:09:15 -0000 1.78
+++ Changes 6 Dec 2002 15:22:25 -0000
@@ -10,6 +10,8 @@

=item 1.99_08-dev

+add $r->as_string [Geoffrey Young]
+
add backcompat vars: $Apache::Server::CWD and
$Apache::Server::AddPerlVersion [Stas Bekman]

Index: t/response/TestAPI/rutil.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/t/response/TestAPI/rutil.pm,v
retrieving revision 1.3
diff -u -r1.3 rutil.pm
--- t/response/TestAPI/rutil.pm 11 Apr 2002 11:08:43 -0000 1.3
+++ t/response/TestAPI/rutil.pm 6 Dec 2002 15:22:26 -0000
@@ -30,7 +30,7 @@
sub handler {
my $r = shift;

- plan $r, tests => 17;
+ plan $r, tests => 18;

ok $r->default_type;

@@ -53,6 +53,11 @@
}

ok $r->is_initial_req;
+
+ # test for the request_line, status_ling, and few
+ # headers that should always be there
+ ok $r->as_string =~
+ m!GET /TestAPI::rutil.*Host:.*200 OK.*Content-Type:!s;

Apache::OK;
}
Index: xs/Apache/RequestUtil/Apache__RequestUtil.h
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/Apache/RequestUtil/Apache__RequestUtil.h,v
retrieving revision 1.12
diff -u -r1.12 Apache__RequestUtil.h
--- xs/Apache/RequestUtil/Apache__RequestUtil.h 5 Dec 2001 19:00:29 -0000 1.12
+++ xs/Apache/RequestUtil/Apache__RequestUtil.h 6 Dec 2002 15:22:26 -0000
@@ -214,3 +214,33 @@

return dcfg->location;
}
+
+static int sv_str_header(void *arg, const char *k, const char *v)
+{
+ SV *sv = (SV*)arg;
+ sv_catpvf(sv, "%s: %s\n", k, v);
+ return 1;
+}
+
+static MP_INLINE
+SV *mpxs_Apache__RequestRec_as_string(pTHX_ request_rec *r)
+{
+ SV *retval = newSVpv(r->the_request, 0);
+
+ sv_catpvn(retval, "\n", 1);
+
+ apr_table_do((int (*) (void *, const char *, const char *))
+ sv_str_header, (void *) retval, r->headers_in, NULL);
+
+ sv_catpvf(retval, "\n%s %s\n", r->protocol, r->status_line);
+
+ apr_table_do((int (*) (void *, const char *, const char *))
+ sv_str_header, (void *) retval, r->headers_out, NULL);
+ apr_table_do((int (*) (void *, const char *, const char *))
+ sv_str_header, (void *) retval, r->err_headers_out, NULL);
+
+ sv_catpvn(retval, "\n", 1);
+
+ return retval;
+}
+
Index: xs/maps/modperl_functions.map
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/maps/modperl_functions.map,v
retrieving revision 1.45
diff -u -r1.45 modperl_functions.map
--- xs/maps/modperl_functions.map 5 Sep 2002 01:48:40 -0000 1.45
+++ xs/maps/modperl_functions.map 6 Dec 2002 15:22:26 -0000
@@ -18,6 +18,7 @@
mpxs_Apache__RequestRec_set_handlers
mpxs_Apache__RequestRec_get_handlers
mpxs_Apache__RequestRec_location
+ mpxs_Apache__RequestRec_as_string
mpxs_Apache__RequestRec_pnotes | | r, key=Nullsv, val=Nullsv
modperl_config_insert_request | | \
r, lines, path=r->filename, override=OR_AUTHCFG | add_config
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.86
diff -u -r1.86 FunctionTable.pm
--- xs/tables/current/ModPerl/FunctionTable.pm 21 Oct 2002 17:58:40 -0000 1.86
+++ xs/tables/current/ModPerl/FunctionTable.pm 6 Dec 2002 15:22:26 -0000
@@ -6242,7 +6242,21 @@
'name' => 'func'
}
]
- }
+ },
+ {
+ 'return_type' => 'SV *',
+ 'name' => 'mpxs_Apache__RequestRec_as_string',
+ 'args' => [
+ {
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
+ {
+ 'type' => 'request_rec *',
+ 'name' => 'r'
+ }
+ ]
+ },
];




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to