/**
 * Attempts to establish the host of an incomming request.
 * That means the hostname of the request that landed up
 * making the request we are experiencing in this context.
 */

public static String getExternalHostnameFromInboundRequest (WORequest request)
    {
                String httpHostHdr = request.headerForKey("http_host");
                
                if((null!=httpHostHdr) && (0!=httpHostHdr.length()))
                        return httpHostHdr.trim();
        
        String hostHdr = request.headerForKey("host");
                                                        
        if(null!=hostHdr)
        {
            int indexOfColon = hostHdr.indexOf(':');

            if(-1!=indexOfColon)
                return hostHdr.substring(0,indexOfColon).trim();

            return hostHdr.trim();
        }
                                                                        
        String serverNameHdr = request.headerForKey("server_name");

        if((null!=serverNameHdr) && (0!=serverNameHdr.length()))
            return serverNameHdr.trim();

        return null;
    }

___
Andrew Lindesay
www.lindesay.co.nz



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to