SK9*_*SK9 13 java android httpurlconnection content-length
对于PUT,我在HttpURLConnection中设置内容的长度.
urlConnection.setRequestProperty("Content-Length", "" + responseJSONArray.toString(2).getBytes("UTF8").length);
Run Code Online (Sandbox Code Playgroud)
实际的字节数是74.但是,当我查询urlConnection我返回的内容长度时-1.这是为什么?为什么长度不相等(假设我设定了这个)?
我必须设置内容长度,因为我收到了411服务器的响应.
(另外,在Sun的例子中,我看到第二个参数setRequestProperty是类型int而不是String,这看起来很奇怪.)