public class MockLowLevelHttpRequest extends LowLevelHttpRequestConstructors
MockLowLevelHttpRequest()
public MockLowLevelHttpRequest()MockLowLevelHttpRequest(String url)
public MockLowLevelHttpRequest(String url)| Name | Description |
| url | StringRequest URL or |
Methods
addHeader(String name, String value)
public void addHeader(String name, String value)Adds a header to the HTTP request.
Note that multiple headers of the same name need to be supported, in which case #addHeader will be called for each instance of the header.
| Name | Description |
| name | String |
| value | String |
| Type | Description |
| IOException |
execute()
public LowLevelHttpResponse execute()Executes the request and returns a low-level HTTP response object.
| Type | Description |
| LowLevelHttpResponse |
| Type | Description |
| IOException |
getContentAsString()
public String getContentAsString()Returns HTTP content as a string, taking care of any encodings of the content if necessary.
Returns an empty string if there is no HTTP content.
| Type | Description |
| String |
| Type | Description |
| IOException |
getFirstHeaderValue(String name)
public String getFirstHeaderValue(String name)Returns the value of the first header of the given name or null for none.
| Name | Description |
| name | Stringheader name (may be any case) |
| Type | Description |
| String |
getHeaderValues(String name)
public List<String> getHeaderValues(String name)Returns the unmodifiable list of values of the headers of the given name (may be empty).
| Name | Description |
| name | Stringheader name (may be any case) |
| Type | Description |
| List<String> |
getHeaders()
public Map<String,List<String>> getHeaders()Returns an unmodifiable view of the map of lowercase header name to values.
Note that unlike this method, #getFirstHeaderValue(String) and #getHeaderValues(String) are not case sensitive with respect to the input header name.
| Type | Description |
| Map<String,List<String>> |
getResponse()
public MockLowLevelHttpResponse getResponse()HTTP response to return from #execute().
| Type | Description |
| MockLowLevelHttpResponse |
getUrl()
public String getUrl()Returns the request URL or null for none.
| Type | Description |
| String |
setResponse(MockLowLevelHttpResponse response)
public MockLowLevelHttpRequest setResponse(MockLowLevelHttpResponse response)Sets the HTTP response to return from #execute().
By default this is a new instance of MockLowLevelHttpResponse.
| Name | Description |
| response | MockLowLevelHttpResponse |
| Type | Description |
| MockLowLevelHttpRequest |
setUrl(String url)
public MockLowLevelHttpRequest setUrl(String url)Sets the request URL or null for none.
| Name | Description |
| url | String |
| Type | Description |
| MockLowLevelHttpRequest |