public class MockLowLevelHttpRequest extends LowLevelHttpRequest
Constructors
MockLowLevelHttpRequest()
public MockLowLevelHttpRequest()
MockLowLevelHttpRequest(String url)
public MockLowLevelHttpRequest(String url)
Parameter | |
---|---|
Name | Description |
url | String Request 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.
Parameters | |
---|---|
Name | Description |
name | String |
value | String |
Exceptions | |
---|---|
Type | Description |
IOException |
execute()
public LowLevelHttpResponse execute()
Executes the request and returns a low-level HTTP response object.
Returns | |
---|---|
Type | Description |
LowLevelHttpResponse |
Exceptions | |
---|---|
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.
Returns | |
---|---|
Type | Description |
String |
Exceptions | |
---|---|
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.
Parameter | |
---|---|
Name | Description |
name | String header name (may be any case) |
Returns | |
---|---|
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).
Parameter | |
---|---|
Name | Description |
name | String header name (may be any case) |
Returns | |
---|---|
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.
Returns | |
---|---|
Type | Description |
Map<String,List<String>> |
getResponse()
public MockLowLevelHttpResponse getResponse()
HTTP response to return from #execute().
Returns | |
---|---|
Type | Description |
MockLowLevelHttpResponse |
getUrl()
public String getUrl()
Returns the request URL or null
for none.
Returns | |
---|---|
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.
Parameter | |
---|---|
Name | Description |
response | MockLowLevelHttpResponse |
Returns | |
---|---|
Type | Description |
MockLowLevelHttpRequest |
setUrl(String url)
public MockLowLevelHttpRequest setUrl(String url)
Sets the request URL or null
for none.
Parameter | |
---|---|
Name | Description |
url | String |
Returns | |
---|---|
Type | Description |
MockLowLevelHttpRequest |