HTTP Requests via Authenticated Proxy

Posted by chrisrichardson on 26-Jul-2017 11:30

A while back I posted this thread

At the time we decided to workaround the proxy issue with our own 4GL socket implementation and some external .net tools.

I've just installed 11.7.1, and am playing around with the http client again.

Is it possible to pass in username & password to the proxy server?  The request below is definitely hitting the proxy server as I'm getting a 302 (Auth Required back).

Tried both options below - is there another way to build the proxy client?  And is authenticated proxy server supported? Any top tips with this?

USING OpenEdge.Net.URI.
USING OpenEdge.Net.HTTP.IHttpRequest.
USING OpenEdge.Net.HTTP.IHttpResponse.
USING OpenEdge.Net.HTTP.IHttpClient.
USING OpenEdge.Net.HTTP.RequestBuilder.
USING OpenEdge.Net.HTTP.ClientBuilder.
DEFINE VARIABLE oRequest    AS IhttpRequest     NO-UNDO.
DEFINE VARIABLE oResponse   AS IhttpResponse    NO-UNDO.

def var oClient as IHttpClient no-undo.

httpUrl = "".

oRequest = RequestBuilder:Get(httpUrl):Request.
oClient = new  OpenEdge.Net.HTTP.ProxyHttpClient(
oResponse = oClient:Execute(oRequest).

*** OR

oRequest = RequestBuilder:Get(httpUrl):ViaProxy('username:password@proxyip:proxyport'):Request.
oResponse = ClientBuilder:Build():Client:Execute(oRequest).

    view-as alert-box info.


All Replies

Posted by Peter Judge on 27-Jul-2017 10:10

The URI’s user/password values are not used for HTTP.
Have you tried setting the Proxy-Authorization header?
oRequest = RequestBuilder:Get(httpUrl)                               
                                                :AddHeader('Proxy-Authorization', base64-encode('name:pw'))    // or whatever

Posted by cSocaciu on 07-Aug-2017 04:46

In my post I have added a working example for a HTTP call with a proxy that uses basic authentication. I have used fiddler and curl in order to analyze the headers and understand the logic needed behind the authentication method.

Do you have a working example for an HTTPS request behind a proxy? I have not succeeded on making an HTTPS call behind a proxy using OpenEdge.Net. If I use CURL that also uses OpenSSL it is working. Maybe this is a bug?

This thread is closed