Gaurav Shukla
Gaurav Shukla

Reputation: 61

How to add custom data in http header

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

Answers (2)

Santosh
Santosh

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

Ronan Quillevere
Ronan Quillevere

Reputation: 3889

Have a look to this article

// adds "X-Hello: World" header to the request
httpChannel.setRequestHeader("X-Hello", "World", false);

Upvotes: 1

Related Questions