|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.api.client.http.AbstractHttpContent
com.google.api.client.http.protobuf.ProtoHttpContent
public class ProtoHttpContent
Serializes of a protocol buffer message to HTTP content.
Sample usage:
static HttpRequest buildPostRequest(
HttpRequestFactory requestFactory, GenericUrl url, MessageLite message) throws IOException {
return requestFactory.buildPostRequest(url, new ProtoHttpContent(message));
}
Implementation is not thread-safe.
Constructor Summary | |
---|---|
ProtoHttpContent(com.google.protobuf.MessageLite message)
|
Method Summary | |
---|---|
long |
getLength()
Default implementation calls AbstractHttpContent.computeLength() once and caches it for future
invocations, but subclasses may override. |
com.google.protobuf.MessageLite |
getMessage()
Returns the message to serialize. |
String |
getType()
Returns the content type or null for none. |
ProtoHttpContent |
setMediaType(HttpMediaType mediaType)
Sets the media type to use for the Content-Type header, or null if unspecified. |
ProtoHttpContent |
setType(String type)
Sets the content type or null for none. |
void |
writeTo(OutputStream out)
Writes the content to the given output stream. |
Methods inherited from class com.google.api.client.http.AbstractHttpContent |
---|
computeLength, getCharset, getEncoding, getMediaType, retrySupported |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ProtoHttpContent(com.google.protobuf.MessageLite message)
message
- message to serializeMethod Detail |
---|
public long getLength() throws IOException
AbstractHttpContent
AbstractHttpContent.computeLength()
once and caches it for future
invocations, but subclasses may override.
getLength
in interface HttpContent
getLength
in class AbstractHttpContent
IOException
public String getType()
HttpContent
null
for none.
getType
in interface HttpContent
getType
in class AbstractHttpContent
public void writeTo(OutputStream out) throws IOException
HttpContent
The recommendation for implementations is that they should not close the output stream. Callers should not assume whether or not the output stream has been closed. Implementations that do not close the output stream should flush it at the end of the method.
IOException
public ProtoHttpContent setType(String type)
null
for none.
Default value is ProtocolBuffers.CONTENT_TYPE
.
public final com.google.protobuf.MessageLite getMessage()
public ProtoHttpContent setMediaType(HttpMediaType mediaType)
AbstractHttpContent
null
if unspecified.
This will also overwrite any previously set parameter of the media type (for example
"charset"
), and therefore might change other properties as well.
setMediaType
in class AbstractHttpContent
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |