• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java URLConnection header

Schadenfroh

Elite Member
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:

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
 
Back
Top