且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用HttpURLConnection设置自定义标头

更新时间:2022-03-04 08:15:51

conn.getHeaderField(CustomHeader)返回响应标头而不是请求一个。

The conn.getHeaderField("CustomHeader") returns the response header not the request one.

要返回请求标头,请使用: conn.getRequestProperty(CustomHeader)

To return the request header use: conn.getRequestProperty("CustomHeader")