|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.api.client.http.LowLevelHttpResponse
com.google.api.client.testing.http.MockLowLevelHttpResponse
public class MockLowLevelHttpResponse
Mock for LowLevelHttpResponse
.
Implementation is not thread-safe.
Constructor Summary | |
---|---|
MockLowLevelHttpResponse()
|
Method Summary | |
---|---|
void |
addHeader(String name,
String value)
Adds a header to the response. |
InputStream |
getContent()
Returns the HTTP response content input stream or null for none. |
String |
getContentEncoding()
Returns the content encoding (for example "gzip" ) or null for none. |
long |
getContentLength()
Returns the content length or 0 for none. |
String |
getContentType()
Returns the content type or null for none. |
int |
getHeaderCount()
Returns the number of HTTP response headers. |
String |
getHeaderName(int index)
Returns the HTTP response header name at the given zero-based index. |
List<String> |
getHeaderNames()
Returns the list of header names of HTTP response. |
String |
getHeaderValue(int index)
Returns the HTTP response header value at the given zero-based index. |
List<String> |
getHeaderValues()
Returns the list of header values of HTTP response. |
String |
getReasonPhrase()
Returns the HTTP reason phrase or null for none. |
int |
getStatusCode()
Returns the response status code or 0 for none. |
String |
getStatusLine()
Returns the response status line or null for none. |
MockLowLevelHttpResponse |
setContent(InputStream content)
Sets the input stream content of HTTP response or null for none. |
MockLowLevelHttpResponse |
setContent(String stringContent)
Sets the response content to the given content string. |
MockLowLevelHttpResponse |
setContentEncoding(String contentEncoding)
Sets the content encoding or null for none. |
MockLowLevelHttpResponse |
setContentLength(long contentLength)
Sets the content length or -1 for unknown. |
MockLowLevelHttpResponse |
setContentType(String contentType)
Sets the content type of HTTP response or null for none. |
MockLowLevelHttpResponse |
setHeaderNames(List<String> headerNames)
Sets the list of header names of HTTP response. |
MockLowLevelHttpResponse |
setHeaderValues(List<String> headerValues)
Sets the list of header values of HTTP response. |
MockLowLevelHttpResponse |
setReasonPhrase(String reasonPhrase)
Sets the HTTP reason phrase or null for none. |
MockLowLevelHttpResponse |
setStatusCode(int statusCode)
Sets the status code of HTTP response. |
Methods inherited from class com.google.api.client.http.LowLevelHttpResponse |
---|
disconnect |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockLowLevelHttpResponse()
Method Detail |
---|
public void addHeader(String name, String value)
name
- header namevalue
- header valuepublic MockLowLevelHttpResponse setContent(String stringContent)
stringContent
- content string or null
for nonepublic InputStream getContent() throws IOException
LowLevelHttpResponse
null
for none.
getContent
in class LowLevelHttpResponse
IOException
- I/O exceptionpublic String getContentEncoding()
LowLevelHttpResponse
"gzip"
) or null
for none.
getContentEncoding
in class LowLevelHttpResponse
public long getContentLength()
LowLevelHttpResponse
0
for none.
getContentLength
in class LowLevelHttpResponse
public final String getContentType()
LowLevelHttpResponse
null
for none.
getContentType
in class LowLevelHttpResponse
public int getHeaderCount()
LowLevelHttpResponse
Note that multiple headers of the same name need to be supported, in which case each header value is treated as a separate header.
getHeaderCount
in class LowLevelHttpResponse
public String getHeaderName(int index)
LowLevelHttpResponse
getHeaderName
in class LowLevelHttpResponse
public String getHeaderValue(int index)
LowLevelHttpResponse
getHeaderValue
in class LowLevelHttpResponse
public String getReasonPhrase()
LowLevelHttpResponse
null
for none.
getReasonPhrase
in class LowLevelHttpResponse
public int getStatusCode()
LowLevelHttpResponse
0
for none.
getStatusCode
in class LowLevelHttpResponse
public String getStatusLine()
LowLevelHttpResponse
null
for none.
getStatusLine
in class LowLevelHttpResponse
public final List<String> getHeaderNames()
public MockLowLevelHttpResponse setHeaderNames(List<String> headerNames)
Default value is an empty list.
public final List<String> getHeaderValues()
Default value is an empty list.
public MockLowLevelHttpResponse setHeaderValues(List<String> headerValues)
public MockLowLevelHttpResponse setContent(InputStream content)
null
for none.
public MockLowLevelHttpResponse setContentType(String contentType)
null
for none.
public MockLowLevelHttpResponse setContentEncoding(String contentEncoding)
null
for none.
public MockLowLevelHttpResponse setContentLength(long contentLength)
-1
for unknown.
By default it is -1
.
Warning: in prior version 0
was the default, but now the default is -1
.
public MockLowLevelHttpResponse setStatusCode(int statusCode)
Default value is 200
.
public MockLowLevelHttpResponse setReasonPhrase(String reasonPhrase)
null
for none.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |