> -----Original Message-----
> From: Doug MacEachern [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 12, 2001 4:29 PM
> To: Geoffrey Young
> Cc: '[EMAIL PROTECTED]'
> Subject: RE: restoring default error response
> 
[snip]

> behavior looks right.
> probably would need to add a reset flag parameter for 
> custom_response(),
> set to 1 if ST(2) == &sv_undef

ok, here's my attempt.  all modperl tests pass and my own seem to work as
well.  I also added two more tests to api.pl for completeness.

lemme know if the Apache.xs needs a different approach, more comments,
etc...

--Geoff

Index: Apache.xs
===================================================================
RCS file: /home/cvspublic/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.121
diff -u -r1.121 Apache.xs
--- Apache.xs   2001/05/01 17:28:37     1.121
+++ Apache.xs   2001/06/13 13:02:24
@@ -238,7 +238,7 @@
 }
 #endif
 
-static char *custom_response(request_rec *r, int status, char *string)
+static char *custom_response(request_rec *r, int status, char *string, int
flag)
 {
     core_dir_config *conf = (core_dir_config *)
        get_module_config(r->per_dir_config, &core_module);
@@ -254,7 +254,10 @@
 
     idx = index_of_response(status);
     retval = conf->response_code_strings[idx];
-    if (string) {
+    if (flag == 1) {
+      conf->response_code_strings[idx] = NULL;
+    }
+    else if (string) {
        conf->response_code_strings[idx] = 
            ((is_url(string) || (*string == '/')) && (*string != '"')) ? 
                pstrdup(r->pool, string) : pstrcat(r->pool, "\"", string,
NULL);
@@ -751,6 +754,18 @@
     Apache     r
     int status
     char *string
+   
+    PREINIT:
+    int flag = 0;
+
+    CODE:
+    if (ST(2) == &sv_undef) {
+      flag = 1;
+    }
+    RETVAL=custom_response(r, status, string, flag);
+
+    OUTPUT:
+    RETVAL
     
 int
 satisfies(r)


Index: api.pl
===================================================================
RCS file: /home/cvspublic/modperl/t/net/perl/api.pl,v
retrieving revision 1.45
diff -u -r1.45 api.pl
--- api.pl      2001/05/01 17:28:41     1.45
+++ api.pl      2001/06/13 13:10:42
@@ -20,7 +20,7 @@
 my $is_win32 = WIN32;
 $tests += 2 unless $is_win32;
 my $test_get_set = Apache->can('set_handlers') && ($tests += 4);
-my $test_custom_response = (MODULE_MAGIC_NUMBER >= 19980324) && ($tests +=
2);
+my $test_custom_response = (MODULE_MAGIC_NUMBER >= 19980324) && ($tests +=
4);
 my $test_dir_config = $INC{'Apache/TestDirectives.pm'} && ($tests += 9);
 
 my $i;
@@ -217,6 +217,8 @@
 if($test_custom_response) {
     test ++$i, $r->custom_response(403, "no chance") || 1;
     test ++$i, $r->custom_response(403) =~ /chance/;
+    test ++$i, $r->custom_response(403, undef) || 1;
+    test ++$i, not defined $r->custom_response(403);
 }
 
 if($test_get_set) {

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

Reply via email to