Skip to content

body delay & headers delay do not work #3970

@Alexander--

Description

@Alexander--

Body delay works for http2 responses only. When used with plain http responses, setBodyDelay acts as one expect setHeadersDelay to act (and setHeadersDelay appears to do nothing).

The following code hangs and times out:

@Test(timeout = 5000)
public void bodyDelayDoesNotWork() throws Exception {
  MockWebServer server = new MockWebServer();

  server.enqueue(new MockResponse()
    .setBodyDelay(1, TimeUnit.DAYS)
    .setResponseCode(200)
    .setBody("Nop"));

  HttpURLConnection conn = (HttpURLConnection) server.url("/").url().openConnection();
  conn.setDoInput(false);
  conn.setDoOutput(false);
  conn.setRequestMethod("HEAD");
  conn.connect();
  Assert.assertEquals(200, conn.getResponseCode());
}

But if you replace .setBodyDelay(1, TimeUnit.DAYS) with .throttleBody(1, 1, TimeUnit.MINUTES), the test passes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug in existing code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions