Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use make HTTP request behind a proxy server

 
Jack Zhou
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was looking for a class like Url and HttpsURLConnection to make a HTTP request via proxy server. No sucess. Can any body give any clue?
 
tommy k. lee
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to work with a proxy, your Java application needs to specify information about the proxy itself as well as specify user information for authentication purposes.

System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "proxyHost", "proxyHost" );
System.getProperties().put( "proxyPort", "85" );

Some proxies require a user to type in a username and password before Internet access is granted. Here's how to perform the authentication:

URLConnection connection = url.openConnection();
String password = "username assword";
String encodedPassword = base64Encode( password );
connection.setRequestProperty( "Proxy-Authorization", encodedPassword );
 
Rajesh Kamisetty
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this (proxy authentication with URLConnection). But didn't work. Do we have to give the Domain name along with the user name like( CORP\USER )? I don't know what to do?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic