public class MockLowLevelHttpResponse extends LowLevelHttpResponse
LowLevelHttpResponse
.
Implementation is not thread-safe.
Constructor and Description |
---|
MockLowLevelHttpResponse() |
Modifier and Type | Method and Description |
---|---|
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.
|
disconnect
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.
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
getContentEncoding
in class LowLevelHttpResponse
public long getContentLength()
LowLevelHttpResponse
0
for none.
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
getContentLength
in class LowLevelHttpResponse
public final String getContentType()
LowLevelHttpResponse
null
for none.
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
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.
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
getHeaderCount
in class LowLevelHttpResponse
public String getHeaderName(int index)
LowLevelHttpResponse
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
getHeaderName
in class LowLevelHttpResponse
public String getHeaderValue(int index)
LowLevelHttpResponse
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
getHeaderValue
in class LowLevelHttpResponse
public String getReasonPhrase()
LowLevelHttpResponse
null
for none.
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
getReasonPhrase
in class LowLevelHttpResponse
public int getStatusCode()
LowLevelHttpResponse
0
for none.
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
getStatusCode
in class LowLevelHttpResponse
public String getStatusLine()
LowLevelHttpResponse
null
for none.
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
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
.
public MockLowLevelHttpResponse setStatusCode(int statusCode)
Default value is 200
.
public MockLowLevelHttpResponse setReasonPhrase(String reasonPhrase)
null
for none.Copyright © 2011-2012 Google. All Rights Reserved.