CronetFixedModeOutputStreamTest.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:chromium-net-for-android 作者:
@SmallTest
@Feature({"Cronet"})
@CompareDefaultWithCronet
public void testWriteLessThanContentLength()
        throws Exception {
    URL url = new URL(NativeTestServer.getEchoBodyURL());
    HttpURLConnection connection =
            (HttpURLConnection) url.openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    // Set a content length that's 1 byte more.
    connection.setFixedLengthStreamingMode(TestUtil.UPLOAD_DATA.length + 1);
    OutputStream out = connection.getOutputStream();
    out.write(TestUtil.UPLOAD_DATA);
    try {
        connection.getResponseCode();
        fail();
    } catch (ProtocolException e) {
        // Expected.
    }
    connection.disconnect();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号