Question OpenEdge HTTP client using Auto Detect Proxy

Cecil

19+ years progress programming and still learning.
Interesting problem to do with internet proxy. Depending on if the end user (Windows) is inside the organization network or exsternal with or without VPN, the access determines if they have access to a proxy server and which one.

I have developed application which uses the OpenEdge HTTP client and it needs to dynamically use the a proxy server depending on the resource location.

I have written a function to try and auto detect which proxy server to use based on it's target URL location but it not working as expected as it's always returning false.

Code:
//USING System.Net.WebProxy.
//USING System.Uri.
//System.Net.WebProxy.

FUNCTION isProxyRequired RETURN LOGICAL (INPUT pchResource        AS CHARACTER,
                                         OUTPUT opchResourceProxy AS CHARACTER):

    DEFINE VARIABLE objWebProxy        AS CLASS  System.Net.WebProxy  NO-UNDO.
    DEFINE VARIABLE objResourceProxy   AS CLASS  System.Uri           NO-UNDO.
    DEFINE VARIABLE objResource        AS CLASS  System.Uri           NO-UNDO.
    DEFINE VARIABLE lgIsProxyRequired  AS LOGICAL                     NO-UNDO.

    objResource = NEW System.Uri(pchResource).
    objWebProxy = NEW System.Net.WebProxy().

    objResourceProxy = objWebProxy:getProxy( objResource ).
    
    MESSAGE
        objWebProxy:address SKIP
        objWebProxy:BypassProxyOnLocal    SKIP
        objWebProxy:BypassList
        
        VIEW-AS ALERT-BOX INFO.

    IF objResourceProxy EQ objResource THEN
        ASSIGN
            lgIsProxyRequired = FALSE.
    ELSE
        ASSIGN
            lgIsProxyRequired = TRUE
            opchResourceProxy = objResourceProxy:ToString().
    
    RETURN lgIsProxyRequired.
    
    
    //Garbage collection
    FINALLY:

        IF VALID-OBJECT(objWebProxy) THEN
            DELETE OBJECT objWebProxy.
            
        IF VALID-OBJECT(objResource) THEN
            DELETE OBJECT objResource.
            
        IF VALID-OBJECT(objResourceProxy) THEN
            DELETE OBJECT objResourceProxy.   
            
            
    END FINALLY.

END FUNCTION.

DEFINE VARIABLE chProxyServer AS CHARACTER   NO-UNDO.

MESSAGE isProxyRequired("http://google.com",
                        OUTPUT chProxyServer) SKIP
                        chProxyServer.
 
Top