- Mar 8, 2003
- 38,416
- 4
- 0
Greetings,
I am working on a Java client that can interact with an HTTP server and I want to be able to send headers to the server upon connection. The way I know to do it is now deprecated and I do not know the proper method of accomplishing it now. So, I need to figure out how to do something like the following:
The problem is that I need to set that header BEFORE I establish a connection. I do not know how to initialize URLConnection without establishing a connection and I need to initialize it in order to set it. Any ideas on how I can go about doing this?
Thanks
I am working on a Java client that can interact with an HTTP server and I want to be able to send headers to the server upon connection. The way I know to do it is now deprecated and I do not know the proper method of accomplishing it now. So, I need to figure out how to do something like the following:
Code:
URL url = new URL("www.anandtech.com");
URLConnection connection = url.openConnection();
connection.addRequestProperty("property name", "value");
The problem is that I need to set that header BEFORE I establish a connection. I do not know how to initialize URLConnection without establishing a connection and I need to initialize it in order to set it. Any ideas on how I can go about doing this?
Thanks