public class MockHttpContent extends Object implements HttpContent
HttpContent.
Implementation is not thread-safe.
| Constructor and Description |
|---|
MockHttpContent() |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getContent()
Returns the HTTP content.
|
String |
getEncoding()
Deprecated.
|
long |
getLength()
Returns the content length or less than zero if not known.
|
String |
getType()
Returns the content type or
null for none. |
boolean |
retrySupported()
Returns whether or not retry is supported on this content type.
|
MockHttpContent |
setContent(byte[] content)
Sets the HTTP content.
|
MockHttpContent |
setEncoding(String encoding)
Deprecated.
(scheduled to be removed in 1.15) Use
HttpEncoding instead. |
MockHttpContent |
setLength(long length)
Returns the HTTP content length or
-1 for unknown. |
MockHttpContent |
setType(String type)
Sets the HTTP content type or
null for none. |
void |
writeTo(OutputStream out)
Writes the byte content to the given output stream.
|
@Deprecated public String getEncoding()
HttpContent"gzip") or null for none.getEncoding in interface HttpContentpublic long getLength()
throws IOException
HttpContentgetLength in interface HttpContentIOExceptionpublic String getType()
HttpContentnull for none.getType in interface HttpContentpublic void writeTo(OutputStream out) throws IOException
HttpContentImplementations must not close the output stream, and instead should flush the output stream. Some callers may assume that the the output stream has not been closed, and will fail to work if it has been closed.
Upgrade warning: in prior version 1.13 the implementation of this method was allowed to close the stream, but starting with 1.14 closing the stream is no longer allowed.
writeTo in interface HttpContentwriteTo in interface StreamingContentout - output streamIOExceptionpublic boolean retrySupported()
HttpContentretrySupported in interface HttpContentpublic final byte[] getContent()
public MockHttpContent setContent(byte[] content)
Default value is an empty byte array.
@Deprecated public MockHttpContent setEncoding(String encoding)
HttpEncoding instead.null for none.public MockHttpContent setLength(long length)
-1 for unknown.
Default value is -1.
public MockHttpContent setType(String type)
null for none.Copyright © 2011-2013 Google. All Rights Reserved.