Class HttpBody (2.23.1)

public final class HttpBody extends GeneratedMessageV3 implements HttpBodyOrBuilder

Message that represents an arbitrary HTTP body. It should only be used for payload formats that can't be represented as JSON, such as raw binary or an HTML page.

This message can be used both in streaming and non-streaming API methods in the request as well as the response.

It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body.

Example:

 message GetResourceRequest {
   // A unique request id.
   string request_id = 1;

   // The raw HTTP body is bound to this field.
   google.api.HttpBody http_body = 2;

 }

 service ResourceService {
   rpc GetResource(GetResourceRequest)
     returns (google.api.HttpBody);
   rpc UpdateResource(google.api.HttpBody)
     returns (google.protobuf.Empty);

 }

Example with streaming methods:

 service CaldavService {
   rpc GetCalendar(stream google.api.HttpBody)
     returns (stream google.api.HttpBody);
   rpc UpdateCalendar(stream google.api.HttpBody)
     returns (stream google.api.HttpBody);

 }

Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.

Protobuf type google.api.HttpBody

Implements

HttpBodyOrBuilder

Static Fields

CONTENT_TYPE_FIELD_NUMBER

public static final int CONTENT_TYPE_FIELD_NUMBER
Field Value
TypeDescription
int

DATA_FIELD_NUMBER

public static final int DATA_FIELD_NUMBER
Field Value
TypeDescription
int

EXTENSIONS_FIELD_NUMBER

public static final int EXTENSIONS_FIELD_NUMBER
Field Value
TypeDescription
int

Static Methods

getDefaultInstance()

public static HttpBody getDefaultInstance()
Returns
TypeDescription
HttpBody

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
TypeDescription
Descriptor

newBuilder()

public static HttpBody.Builder newBuilder()
Returns
TypeDescription
HttpBody.Builder

newBuilder(HttpBody prototype)

public static HttpBody.Builder newBuilder(HttpBody prototype)
Parameter
NameDescription
prototypeHttpBody
Returns
TypeDescription
HttpBody.Builder

parseDelimitedFrom(InputStream input)

public static HttpBody parseDelimitedFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static HttpBody parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
IOException

parseFrom(byte[] data)

public static HttpBody parseFrom(byte[] data)
Parameter
NameDescription
databyte[]
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static HttpBody parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
databyte[]
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data)

public static HttpBody parseFrom(ByteString data)
Parameter
NameDescription
dataByteString
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static HttpBody parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteString
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static HttpBody parseFrom(CodedInputStream input)
Parameter
NameDescription
inputCodedInputStream
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static HttpBody parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputCodedInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
IOException

parseFrom(InputStream input)

public static HttpBody parseFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static HttpBody parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
IOException

parseFrom(ByteBuffer data)

public static HttpBody parseFrom(ByteBuffer data)
Parameter
NameDescription
dataByteBuffer
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static HttpBody parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteBuffer
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
HttpBody
Exceptions
TypeDescription
InvalidProtocolBufferException

parser()

public static Parser<HttpBody> parser()
Returns
TypeDescription
Parser<HttpBody>

Methods

equals(Object obj)

public boolean equals(Object obj)
Parameter
NameDescription
objObject
Returns
TypeDescription
boolean
Overrides

getContentType()

public String getContentType()

The HTTP Content-Type header value specifying the content type of the body.

string content_type = 1;

Returns
TypeDescription
String

The contentType.

getContentTypeBytes()

public ByteString getContentTypeBytes()

The HTTP Content-Type header value specifying the content type of the body.

string content_type = 1;

Returns
TypeDescription
ByteString

The bytes for contentType.

getData()

public ByteString getData()

The HTTP request/response body as raw binary.

bytes data = 2;

Returns
TypeDescription
ByteString

The data.

getDefaultInstanceForType()

public HttpBody getDefaultInstanceForType()
Returns
TypeDescription
HttpBody

getExtensions(int index)

public Any getExtensions(int index)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
NameDescription
indexint
Returns
TypeDescription
Any

getExtensionsCount()

public int getExtensionsCount()

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Returns
TypeDescription
int

getExtensionsList()

public List<Any> getExtensionsList()

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Returns
TypeDescription
List<Any>

getExtensionsOrBuilder(int index)

public AnyOrBuilder getExtensionsOrBuilder(int index)

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Parameter
NameDescription
indexint
Returns
TypeDescription
AnyOrBuilder

getExtensionsOrBuilderList()

public List<? extends AnyOrBuilder> getExtensionsOrBuilderList()

Application specific response metadata. Must be set in the first response for streaming APIs.

repeated .google.protobuf.Any extensions = 3;

Returns
TypeDescription
List<? extends com.google.protobuf.AnyOrBuilder>

getParserForType()

public Parser<HttpBody> getParserForType()
Returns
TypeDescription
Parser<HttpBody>
Overrides

getSerializedSize()

public int getSerializedSize()
Returns
TypeDescription
int
Overrides

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
TypeDescription
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
TypeDescription
boolean
Overrides

newBuilderForType()

public HttpBody.Builder newBuilderForType()
Returns
TypeDescription
HttpBody.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected HttpBody.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Parameter
NameDescription
parentBuilderParent
Returns
TypeDescription
HttpBody.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Parameter
NameDescription
unusedUnusedPrivateParameter
Returns
TypeDescription
Object
Overrides

toBuilder()

public HttpBody.Builder toBuilder()
Returns
TypeDescription
HttpBody.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
NameDescription
outputCodedOutputStream
Overrides
Exceptions
TypeDescription
IOException