Today i was struggling with misbehaviour of mod_rewrite SERVER_PORT on non default apache2 port. I found that, in both newest legacy and current versions, modules/http/http_core.c there is a function apr_port_t that return either 80 or 443, based on ssl configuration. Shouldn't this function return current used port?
I guess you talk about: apr_port_t http_port(const request_rec *r) if correct, then the answer is no. This function is there to give the default http or https port number (i.e. 443 or 80) If you are not talking about this function, then you should provide additional description in order to help us check if there is an issue or not.