• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Sending custom http headers through HttpClient

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to use Apache's HttpClient to send http request header. Can anyone take a look into my code and see if it is correct? (I am using msn's web site for testing purpose)

String url = "http://www.msn.com";
HttpClient client = new HttpClient();
GetMethod get = new GetMethod(url);


get.setRequestHeader("CT_REMOTE_USER", "SXYANGET");
get.setRequestHeader("ETRANAUTH", etranAuthStr2);



I use a debugging tool called "Fiddler" to see the request headers being sent, and looks like the headers are not sending over. did I miss anything? anyone has any idea?
sharon yang
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I thought it didn't work, but actually I was wrong, the headers were sent.

I have another problem. the url I am sending my request to is the login page of another application (written in asp.net). I used "www.msn.com" in my example just for testing purpose. When I sent the request to the login page, it redirected to the home page, but the images and styles were lost.

Anyone has thoughts? Thank you in advance for your help.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!