Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help : proxy server !!!!

 
Ashley Pratt
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to get thru the proxy server which requires authentication.
Here is my code but I am getting hangs in between.
Can anyone helps me out:
HttpConnection c = (HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.GET);
String password = "username : password";
base=new Base64Encoder();
String encodedPassword = base.encode(password);
c.setRequestProperty( "Proxy-Authorization", "Basic" +encodedPassword );
c.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Confirguration/CLDC-1.0");
c.setRequestProperty("Content-Language", "en-CA");
is = c.openDataInputStream(); //It hangs here throws IOException
len = c.getLength();
if( len != -1)
{
// Read exactly Content-Length bytes
for(int i =0 ; i < len ; i++ )
{
System.out.println("4");
if((ch = is.read()) != -1)
{
System.out.println("5");
b.append((char) ch);
}
}
}
else
{
//Read until the connection is closed.
while ((ch = is.read()) != -1)
{
len = is.available() ;
b.append((char)ch);
}
}
Can anyone help..
any help will be great..
thanks,
[ July 24, 2002: Message edited by: Ashley Love ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic