Reputation: 61
I want to add some custom data in http header and send it to another web application so I can access that data. How can I do that, please help.
Upvotes: 1
Views: 1722
Reputation: 17893
Easiest way to do is use java.net.HttpURLConnection.addRequestProperty()
method. E.g
httpURLConnection.addRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
Check documentation for more details.
Upvotes: 1
Reputation: 3889
Have a look to this article
// adds "X-Hello: World" header to the request
httpChannel.setRequestHeader("X-Hello", "World", false);
Upvotes: 1