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 com.google.api.client.http.LowLevelHttpRequest
getContentEncoding, getContentLength, getContentType, getStreamingContent, setContentEncoding, setContentLength, setContentType, setStreamingContent, setTimeout, setWriteTimeout
-
Field Details
-
url
Request URL ornullfor none. -
headersMap
Map of lowercase header name to values. -
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(java.lang.String, java.lang.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
Returns the request URL ornullfor none.- Since:
- 1.5
-
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
Returns the value of the first header of the given name ornullfor none.- Parameters:
name- header name (may be any case)- Since:
- 1.13
-
getHeaderValues
Returns the unmodifiable list of values of the headers of the given name (may be empty).- Parameters:
name- header name (may be any case)- Since:
- 1.13
-
setUrl
Sets the request URL ornullfor none.- Since:
- 1.5
-
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
HTTP response to return fromexecute().- Since:
- 1.8
-
setResponse
Sets the HTTP response to return fromexecute().By default this is a new instance of
MockLowLevelHttpResponse.
-