doh! this breaks the api.t test.
hmm, the test calls $r->custom_response(403) - no second parameter.
my C friends here tell me that being able to call custom_response with only
one argument works only by accident. I dunno.
at any rate, $r->custom_response(VAL) isn't documented as far as I can tell
(although I have also used it that way myself) and a quick grep of CPAN
doesn't show it used this way there as well...
anyway, short of disallowing the single parameter form of custom_response
(which would mean that you could never just inspect the current
ErrorDocument setting), does
anyone have an ideas how to implement (what I think, at least) would be the
proper behavior:
one arg - return current config
two args, second arg defined - set config
two args, second undef - reset default response
thanks
--Geoff
> -----Original Message-----
> From: Geoffrey Young [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 01, 2001 11:42 AM
> To: '[EMAIL PROTECTED]'
> Subject: restoring default error response
>
>
> hi all...
>
> I was playing around with custom response and noticed that
> you couldn't
> reset the default Apache response after setting a custom response:
>
> # where "old" describes a lack of any ErrorDocument configs
> my $old = $r->custom_response(SERVER_ERROR, "/error.html");
>
> # blammo - no data
> my $new = $r->custom_response(SERVER_ERROR, $old);
>
> # or just plain undef to get core Apache back
> $r->custom_response(SERVER_ERROR, undef());
>
>
> this seems to work while still returning the current ErrorDocument...
>
> --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/01 15:32:20
> @@ -254,10 +254,15 @@
>
> idx = index_of_response(status);
> retval = conf->response_code_strings[idx];
> - if (string) {
> + if (*string) {
> + /* they passed in a response string */
> conf->response_code_strings[idx] =
> ((is_url(string) || (*string == '/')) && (*string
> != '"')) ?
> pstrdup(r->pool, string) : pstrcat(r->pool,
> "\"", string,
> NULL);
> + }
> + else {
> + /* they tried to undef the custom response */
> + conf->response_code_strings[idx] = NULL;
> }
>
> return retval;
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]