Class MockHttpUnsuccessfulResponseHandler (1.42.2)

Stay organized with collections Save and categorize content based on your preferences.
public class MockHttpUnsuccessfulResponseHandler implements HttpUnsuccessfulResponseHandler

Beta
Mock for HttpUnsuccessfulResponseHandler.

Contains an #isCalled method that returns true if #handleResponse is called.

Inheritance

java.lang.Object > MockHttpUnsuccessfulResponseHandler

Constructors

MockHttpUnsuccessfulResponseHandler(boolean successfullyHandleResponse)

public MockHttpUnsuccessfulResponseHandler(boolean successfullyHandleResponse)

Create an instance of MockHttpUnsuccessfulResponseHandler.

Parameter
NameDescription
successfullyHandleResponseboolean

This will be the return value of #handleResponse

Methods

handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry)

public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry)

Handler that will be invoked when an abnormal response is received. There are a few simple rules that one must follow:

  • If you modify the request object or modify its execute interceptors in a way that should resolve the error, you must return true to issue a retry.
  • Do not read from the content stream, this will prevent the eventual end user from having access to it.
Parameters
NameDescription
requestHttpRequest
responseHttpResponse
supportsRetryboolean
Returns
TypeDescription
boolean
Exceptions
TypeDescription
IOException

isCalled()

public boolean isCalled()

Returns whether the #handleResponse method was called or not.

Returns
TypeDescription
boolean