Class MockLowLevelHttpRequest
java.lang.Object
com.google.api.client.http.LowLevelHttpRequest
com.google.api.client.testing.http.MockLowLevelHttpRequest
- Since:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionMap of lowercase header name to values.private MockLowLevelHttpResponseHTTP response to return fromexecute().private StringRequest URL ornullfor none. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a header to the HTTP request.execute()Executes the request and returns a low-level HTTP response object.Returns HTTP content as a string, taking care of any encodings of the content if necessary.getFirstHeaderValue(String name) Returns the value of the first header of the given name ornullfor none.Returns an unmodifiable view of the map of lowercase header name to values.getHeaderValues(String name) Returns the unmodifiable list of values of the headers of the given name (may be empty).HTTP response to return fromexecute().getUrl()Returns the request URL ornullfor none.setResponse(MockLowLevelHttpResponse response) Sets the HTTP response to return fromexecute().Sets the request URL ornullfor none.Methods inherited from class LowLevelHttpRequest
getContentEncoding, getContentLength, getContentType, getStreamingContent, setContentEncoding, setContentLength, setContentType, setStreamingContent, setTimeout, setWriteTimeout
-
Field Details
-
url
Request URL ornullfor none. -
headersMap
-
response
HTTP response to return fromexecute().By default this is a new instance of
MockLowLevelHttpResponse.
-
-
Constructor Details
-
MockLowLevelHttpRequest
public MockLowLevelHttpRequest() -
MockLowLevelHttpRequest
- Parameters:
url- Request URL ornullfor none- Since:
- 1.4
-
-
Method Details
-
addHeader
Description copied from class:LowLevelHttpRequestAdds a header to the HTTP request.Note that multiple headers of the same name need to be supported, in which case
LowLevelHttpRequest.addHeader(String, String)will be called for each instance of the header.- Specified by:
addHeaderin classLowLevelHttpRequest- Parameters:
name- header namevalue- header value- Throws:
IOException
-
execute
Description copied from class:LowLevelHttpRequestExecutes the request and returns a low-level HTTP response object.- Specified by:
executein classLowLevelHttpRequest- Throws:
IOException
-
getUrl
-
getHeaders
Returns an unmodifiable view of the map of lowercase header name to values.Note that unlike this method,
getFirstHeaderValue(String)andgetHeaderValues(String)are not case sensitive with respect to the input header name.- Since:
- 1.5
-
getFirstHeaderValue
-
getHeaderValues
-
setUrl
-
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.
- Throws:
IOException- Since:
- 1.12
-
getResponse
-
setResponse
Sets the HTTP response to return fromexecute().By default this is a new instance of
MockLowLevelHttpResponse.
-