Reputation: 21329
How do I send request headers ? Suppose I want to send my own request header when I make an HTTP request to a website.
How do I do that ?
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// HOW DO I SEND REQUEST HEADER LIKE Date,Cookie,Cache-Control ???
Upvotes: 0
Views: 180
Reputation: 12890
After getting the HttpURLConnection connection, you can do that as follows
//adding headers
con.setRequestProperty("headername", value);
Upvotes: 2