#20 Add support for acting behind a proxy

devel
closed
nobody
core (5)
5
2013-04-05
2011-01-20
Anonymous
No

Hi,
in our company we are using a proxy environment.
Your code currently doesn't have support for this. I found some lines of code to work with Apache HttpClient 4.x:
Add something like
HttpHost proxy = new HttpHost(myProxyHost, myProxyPort, "http");
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
httpclient.getCredentialsProvider().setCredentials(
new AuthScope(myProxyHost, myProxyPort),
new UsernamePasswordCredentials(myUsername, myPassword));

Perhaps these credentials and proxy settings should add as a part of the MediaWikiBot constructor.
Or you may have a better idea.
Thanks
Elmar

Discussion

  • Loki

    Loki - 2011-01-20

    What do you think about:

    public static MediaWikiBot newBot(URL url) {
    HttpClient httpclient = newClient();
    HttpHost proxy = new HttpHost(myProxyHost, myProxyPort, "http");
    httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    httpclient.getCredentialsProvider().setCredentials(
    new AuthScope(myProxyHost, myProxyPort),
    new UsernamePasswordCredentials(myUsername, myPassword));

    return new MediaWikiBot(new HttpActionClient(httpclient, url));
    }

     
  • Elmar Schalück

    Elmar Schalück - 2011-01-21

    Yes, the following works:

    public static MediaWikiBot newBot(URL url) {
    DefaultHttpClient httpclient = new DefaultHttpClient();
    HttpHost proxy = new HttpHost(myProxyServer, myProxyHost, "http");
    httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
    proxy);
    httpclient.getCredentialsProvider().setCredentials(
    new AuthScope(myProxyServer, myProxyHost),
    new UsernamePasswordCredentials(myUsername, myUserpassword));
    MediaWikiBot bot = new MediaWikiBot(url);
    bot.setConnection(new HttpActionClient(httpclient, url));
    return bot;
    }

    Your suggestion lacks the constructor of the bot with a dedicated HttpActionClient.

    So you may close this request, but you may put to the list of examples.
    Thanks
    Elmar

     
  • Loki

    Loki - 2013-04-05
    • status: open --> closed
    • milestone: --> devel
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks