You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Fred Moyer <fr...@taperfriendlymusic.org> on 2007/11/30 23:31:49 UTC

$r->headers_out->set('Server' => 'foo');

Greetings,

I'm trying to figure out where in the mod_perl innards I need to look to 
  map the accessor for the Server header.

I've changed core.c in httpd so that set_banner() is deactivated.  This 
results in a Server header of 'mod_perl/2.0.4-dev Perl/v5.8.8', so I 
think that change is all that is needed to keep apache from overwriting 
the header.

I don't see anything in xs/maps/apache2_structures.map so I figure that 
I have to add server in there somehow?

Thanks in advance,

Fred

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: $r->headers_out->set('Server' => 'foo');

Posted by Fred Moyer <fr...@taperfriendlymusic.org>.
Geoffrey Young wrote:
> 
> Fred Moyer wrote:
>> Greetings,
>>
>> I'm trying to figure out where in the mod_perl innards I need to look to
>>  map the accessor for the Server header.
> 
> mod_perl.c - grep for ap_add_version_component
> 
>> I've changed core.c in httpd so that set_banner() is deactivated.  This
>> results in a Server header of 'mod_perl/2.0.4-dev Perl/v5.8.8', so I
>> think that change is all that is needed to keep apache from overwriting
>> the header.
>>
>> I don't see anything in xs/maps/apache2_structures.map so I figure that
>> I have to add server in there somehow?
> 
> you can call add_version_component() from perl, IIRC.  but httpd will
> always override the Server header, so the syntax in the subject will
> never dwym.

I was able to hack ap_add_version_component to dwim.  So when I call 
add_version_component() in perl now I can set the outgoing server header 
to whatever I want.  This hack is pretty lame but it took me all of a 
few minutes to get working which was kind of nice.  I suppose I could 
make set_version_component call apr_pstrdup() instead of this hack.

--- server/core.c       2006-09-15 06:19:25.000000000 -0700
+++ server/core.c       2007-11-30 14:53:21.000000000 -0800
@@ -2751,28 +2751,32 @@

  AP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const 
char *component)
  {
-    if (! banner_locked) {
+
+    server_banner = apr_pstrdup(pconf, component);
+    server_description = apr_pstrdup(pconf, component);
+
+    /* if (! banner_locked) { */
          /*
           * If the version string is null, register our cleanup to 
reset the
           * pointer on pool destruction. We also know that, if NULL,
           * we are adding the original SERVER_BASEVERSION string.
           */
-        if (server_banner == NULL) {
+/*        if (server_banner == NULL) {
              apr_pool_cleanup_register(pconf, NULL, reset_banner,
                                        apr_pool_cleanup_null);
              server_banner = apr_pstrdup(pconf, component);
          }
-        else {
+        else { */
              /*
               * Tack the given component identifier to the end of
               * the existing string.
               */
-            server_banner = apr_pstrcat(pconf, server_banner, " ",
+/*            server_banner = apr_pstrcat(pconf, server_banner, " ",
                                          component, NULL);
          }
      }
      server_description = apr_pstrcat(pconf, server_description, " ",
-                                     component, NULL);
+                                     component, NULL); */
  }

  /*
@@ -3775,7 +3779,7 @@
      logio_add_bytes_out = 
APR_RETRIEVE_OPTIONAL_FN(ap_logio_add_bytes_out);
      ident_lookup = APR_RETRIEVE_OPTIONAL_FN(ap_ident_lookup);

-    set_banner(pconf);
+    /* set_banner(pconf); */
      ap_setup_make_content_type(pconf);
      return OK;
  }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: $r->headers_out->set('Server' => 'foo');

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Fred Moyer wrote:
> Greetings,
> 
> I'm trying to figure out where in the mod_perl innards I need to look to
>  map the accessor for the Server header.

mod_perl.c - grep for ap_add_version_component

> 
> I've changed core.c in httpd so that set_banner() is deactivated.  This
> results in a Server header of 'mod_perl/2.0.4-dev Perl/v5.8.8', so I
> think that change is all that is needed to keep apache from overwriting
> the header.
> 
> I don't see anything in xs/maps/apache2_structures.map so I figure that
> I have to add server in there somehow?

you can call add_version_component() from perl, IIRC.  but httpd will
always override the Server header, so the syntax in the subject will
never dwym.

HTH

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org