CronetUrlRequestTest.java 文件源码

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

项目:chromium-net-for-android 作者:
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet // No canonical exception to assert on
public void testContentLengthMismatchFailsOnce() throws Exception {
    String url = NativeTestServer.getFileURL(
            "/content_length_mismatch.html");
    TestUrlRequestCallback callback = startAndWaitForComplete(url);
    assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
    // The entire response body will be read before the error is returned.
    // This is because the network stack returns data as it's read from the
    // socket, and the socket close message which triggers the error will
    // only be passed along after all data has been read.
    assertEquals("Response that lies about content length.", callback.mResponseAsString);
    assertNotNull(callback.mError);
    assertEquals("Exception in CronetUrlRequest: net::ERR_CONTENT_LENGTH_MISMATCH",
            callback.mError.getMessage());
    // Wait for a couple round trips to make sure there are no pending
    // onFailed messages. This test relies on checks in
    // TestUrlRequestCallback catching a second onFailed call.
    testSimpleGet();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号