@Beta public class MockLowLevelHttpRequest extends LowLevelHttpRequest
| Constructor and Description |
|---|
MockLowLevelHttpRequest()
|
MockLowLevelHttpRequest(String
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String
Adds a header to the HTTP request.
|
LowLevelHttpResponse |
execute()
Executes the request and returns a low-level HTTP response object.
|
String |
getContentAsString()
Returns HTTP content as a string, taking care of any encodings of the content if necessary.
|
String |
getFirstHeaderValue(String
Returns the value of the first header of the given name or
null for none.
|
Map |
getHeaders()
Returns an unmodifiable view of the map of lowercase header name to values.
|
List |
getHeaderValues(String
Returns the unmodifiable list of values of the headers of the given name (may be empty).
|
MockLowLevelHttpResponse |
getResponse()
HTTP response to return from
execute().
|
String |
getUrl()
Returns the request URL or
null for none.
|
MockLowLevelHttpRequest |
setResponse(MockLowLevelHttpResponse
Sets the HTTP response to return from
execute().
|
MockLowLevelHttpRequest |
setUrl(String
Sets the request URL or
null for none.
|
getContentEncoding, getContentLength, getContentType, getStreamingContent, setContentEncoding, setContentLength, setContentType, setStreamingContent, setTimeoutpublic MockLowLevelHttpRequest()
public MockLowLevelHttpRequest(Stringurl)
url - Request URL or
null for none
public void addHeader(Stringname, String value) throws IOException
LowLevelHttpRequest
Note that multiple headers of the same name need to be supported, in which case LowLevelHttpRequest will be called for each instance of the header.
addHeader in class
LowLevelHttpRequest
name - header name
value - header value
IOException
public LowLevelHttpResponseexecute() throws IOException
LowLevelHttpRequest
execute in class
LowLevelHttpRequest
IOException
public StringgetUrl()
null for none.
public Map<String ,List <String >> getHeaders()
Note that unlike this method, getFirstHeaderValue(String) and getHeaderValues(String) are not case sensitive with respect to the input header name.
public StringgetFirstHeaderValue(String name)
null for none.
name - header name (may be any case)
public List<String > getHeaderValues(String name)
name - header name (may be any case)
public MockLowLevelHttpRequestsetUrl(String url)
null for none.
public StringgetContentAsString() throws IOException
Returns an empty string if there is no HTTP content.
IOException
public MockLowLevelHttpResponsegetResponse()
execute().
public MockLowLevelHttpRequestsetResponse(MockLowLevelHttpResponse response)
execute().
By default this is a new instance of MockLowLevelHttpResponse.