httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Akins <brian.ak...@turner.com>
Subject Re: ap_get_server_port differences
Date Fri, 11 Nov 2005 20:58:33 GMT
Here's the quick workaround module.  Just load the modules and it tries 
to "revert" to 2.0 behavior

#include "httpd.h"
#include "http_config.h"
#include "ap_config.h"
#include "apr_strings.h"
#include "http_protocol.h"

module AP_MODULE_DECLARE_DATA port_module;

typedef struct {
     apr_port_t port;
     char *port_str;
} port_config;


static int port(request_rec *r)
{
     port_config *conf;

     if((conf = ap_get_module_config(r->server->module_config, 
&port_module)) != NULL) {
         if(conf->port_str) {
             /*looking at server/core.c, ap_get_server_port This looks 
to be the best place
              * UseCanonicalName MUST be off, or this is ignored*/
             r->parsed_uri.port     = conf->port;
             r->parsed_uri.port_str = conf->port_str;
         }
     }

     return DECLINED;
}

static int post_config(apr_pool_t * pconf, apr_pool_t * plog,
                   apr_pool_t * ptemp, server_rec *s)
{
     server_rec *virt;
     port_config *port;

     for(virt = s; virt; virt = virt->next) {
         port = apr_pcalloc(pconf, sizeof(port_config));
         if(virt->port) {
             port->port = virt->port;
             port->port_str = apr_psprintf(pconf, "%u", virt->port);
             ap_set_module_config(virt->module_config, &port_module, port);
         }

     }

     return OK;
}

static void register_hooks(apr_pool_t * p)
{
     ap_hook_post_read_request(port, NULL, NULL, APR_HOOK_REALLY_FIRST);
     ap_hook_post_config(post_config, NULL, NULL, APR_HOOK_MIDDLE);
}

/* Dispatch list for API hooks */
module AP_MODULE_DECLARE_DATA port_module = {
     STANDARD20_MODULE_STUFF,
     NULL,       /* create per-dir    config structures */
     NULL,        /* merge  per-dir    config structures */
     NULL,   /* create per-server config structures */
     NULL,                       /* merge  per-server config structures */
     NULL,            /* table of config file commands       */
     register_hooks   /* register hooks                      */
};


-- 
Brian Akins
Lead Systems Engineer
CNN Internet Technologies

Mime
View raw message