public class MockHttpUnsuccessfulResponseHandler implements HttpUnsuccessfulResponseHandler
Beta
Mock for HttpUnsuccessfulResponseHandler.
Contains an #isCalled method that returns true if #handleResponse is called.
Implements
HttpUnsuccessfulResponseHandlerConstructors
MockHttpUnsuccessfulResponseHandler(boolean successfullyHandleResponse)
public MockHttpUnsuccessfulResponseHandler(boolean successfullyHandleResponse)
Create an instance of MockHttpUnsuccessfulResponseHandler
.
Parameter | |
---|---|
Name | Description |
successfullyHandleResponse | boolean 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 | |
---|---|
Name | Description |
request | HttpRequest |
response | HttpResponse |
supportsRetry | boolean |
Returns | |
---|---|
Type | Description |
boolean |
Exceptions | |
---|---|
Type | Description |
IOException |
isCalled()
public boolean isCalled()
Returns whether the #handleResponse method was called or not.
Returns | |
---|---|
Type | Description |
boolean |