Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delay MockWebServer response

How can I delay a Square MockWebServer HTTP response?

There is a response.setBodyDelayTimeMs(...); method but this is only used in SpdySocketHandler and not for HTTP requests.

like image 235
Ralph Bergmann Avatar asked Nov 06 '14 11:11

Ralph Bergmann


2 Answers

That's a bug that we OkHttp maintainers need to fix. If you report it on our issue tracker, we'll tale care of it. Or better yet, send us a pull request!

like image 186
Jesse Wilson Avatar answered Sep 20 '22 11:09

Jesse Wilson


response.setBodyDelay(10, TimeUnit.SECONDS)

This should now work for HTTP requests as well.

like image 22
Life Of Pai Avatar answered Sep 20 '22 11:09

Life Of Pai