What is the proper way of setting headers in a URLConnection?

前端 未结 3 826
粉色の甜心
粉色の甜心 2020-12-10 01:32

My code is like the following:

URLConnection cnx = address.openConnection();
cnx.setAllowUserInteraction(false);         
cnx.setDoOutput(true);
cnx.addReque         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 02:08

    I'd advise against using low-level constructs such as URLConnection. There are plenty of libraries for sending HTTP requests, with the most prominent being Apache HTTP Client.

提交回复
热议问题