在HttpURLConnection.setChunkedStreamingMode()的文档中,如果我在参数中指定0,则会使用默认分块长度。
conn.setChunkedStreamingMode(0);
默认块长度的精确值是多少?参数的单位是什么?以字节为单位。
conn.setChunkedStreamingMode(0);
默认块长度的精确值是多少?参数的单位是什么?以字节为单位。
class HttpTest extends HttpURLConnection {
protected HttpTest(URL url) {
super(url);
Log.d("CHUNKLENGTH", String.format("%d", this.chunkLength));
this.setChunkedStreamingMode(0);
Log.d("CHUNKLENGTH", String.format("%d", this.chunkLength));
}
@Override
public void disconnect() {
// TODO Auto-generated method stub
}
@Override
public boolean usingProxy() {
// TODO Auto-generated method stub
return false;
}
@Override
public void connect() throws IOException {
// TODO Auto-generated method stub
}
}
像这样调用
try {
HttpTest test = new HttpTest(new URL("http://www.google.com/"));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
这些是结果
从中我们可以得出结论,它使用的默认值为1024。