Hello,

I noticed some interesting behavior when retrieving the port of a subrequest
and am trying to determine if it's a bug or by design. Basically, the sub-
request's parsed_uri port fields aren't preserved from the main request. With
default canonical name settings, this leads to ap_get_server_port falling back
to the port from the ServerName, whereas calling ap_get_server_port on the
main request would use the port from the host header, potentially giving
different results.

You can see this effect using mod_rewrite and lookahead variables:

    Listen 9090
    ServerName localhost:9092

    <Directory "${DOCROOT}/port">
        RewriteEngine On
        RewriteRule ^ /?port=%{SERVER_PORT}&la-port=%{LA-U:SERVER_PORT} [R]
    </Directory>

A request to localhost:9090/port redirects to /?port=9090&la-port=9092

This is different than internal redirects, which copy the port fields upon
creating the new request (see internal_internal_redirect in http_request.c).
The attached trunk patch would do the same for subrequests created via
ap_sub_req_method_uri (but not for others). I also tried writing a test case,
but httpd-test specifies a ServerName, and I'm not familiar enough with the
framework to get around that.

Any thoughts on the expected behavior would be appreciated.

Regards,
Paul Spangler
LabVIEW R&D
National Instruments

Attachment: subrequest_port.patch
Description: subrequest_port.patch

Reply via email to