17

I'm trying to test HTTP timeout scenarios using a MockWebServer which answers my test requests sent with Retrofit/OkHttp. (This question was asked before some years ago, but at the time concerned a bug in the MockWebServer. Also, the API has since changed a fair bit, so I think reposting this question is warranted.)

There seem to be several related methods, but I'd appreciate a solution to this issue with a clear example: I'm unsure about the difference between..

  • .delayBody and
  • .throttleBody

Also, both of these methods seem to only delay/throttle the body - is it not possible to set a timeout for the response header? I.e. something along the lines of "wait X seconds after the next incoming request before you send out any response".

4

1 回答 1

31

Try setting the response’s socket policy to NO_RESPONSE.

于 2016-09-23T03:05:02.333 回答