• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

how to use make HTTP request behind a proxy server

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 );
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic