MockWebServer Response Delay - Test Timeout

I am trying to test HTTP timeout scripts using MockWebServer, which responds to my test requests sent using Retrofit / OkHttp. (This question was asked a few years ago, but at the time it was related to an error in MockWebServer. In addition, the API has since changed the fair bit, so I think the retransmission of this question is justified.)

It seems that there are several related methods, but I would appreciate a solution to this problem with a clear example: I am not sure about the difference between the two.

  • .delayBody and
  • .throttleBody

In addition, both of these methods seem to only delay / throttle the body - is it possible to set a timeout for the response header? That is, something like the lines "wait X seconds after the next incoming request before sending any response."

+4
source share
1 answer

Try setting the response socket policy to NO_RESPONSE.

+7
source

Source: https://habr.com/ru/post/1655472/


All Articles