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 MockLowLevelHttpResponse
HTTP response to return fromexecute()
.private String
Request URL ornull
for none. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds 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 ornull
for 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 ornull
for none.setResponse
(MockLowLevelHttpResponse response) Sets the HTTP response to return fromexecute()
.Sets the request URL ornull
for none.Methods inherited from class com.google.api.client.http.LowLevelHttpRequest
getContentEncoding, getContentLength, getContentType, getStreamingContent, setContentEncoding, setContentLength, setContentType, setStreamingContent, setTimeout
-
Field Details
-
url
Request URL ornull
for 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 ornull
for none- Since:
- 1.4
-
-
Method Details
-
addHeader
Description copied from class:LowLevelHttpRequest
Adds 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:
addHeader
in classLowLevelHttpRequest
- Parameters:
name
- header namevalue
- header value- Throws:
IOException
-
execute
Description copied from class:LowLevelHttpRequest
Executes the request and returns a low-level HTTP response object.- Specified by:
execute
in classLowLevelHttpRequest
- Throws:
IOException
-
getUrl
Returns the request URL ornull
for 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 ornull
for 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 ornull
for 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
.
-