Class HttpRequest

  • All Implemented Interfaces:
    HttpRequestOrBuilder, com.google.protobuf.Message, com.google.protobuf.MessageLite, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, Serializable

    public final class HttpRequest
    extends com.google.protobuf.GeneratedMessageV3
    implements HttpRequestOrBuilder
     HTTP request.
    
     The task will be pushed to the worker as an HTTP request. If the worker
     or the redirected worker acknowledges the task by returning a successful HTTP
     response code ([`200` - `299`]), the task will be removed from the queue. If
     any other HTTP response code is returned or no response is received, the
     task will be retried according to the following:
    
     * User-specified throttling: [retry
     configuration][google.cloud.tasks.v2.Queue.retry_config],
       [rate limits][google.cloud.tasks.v2.Queue.rate_limits], and the [queue's
       state][google.cloud.tasks.v2.Queue.state].
    
     * System throttling: To prevent the worker from overloading, Cloud Tasks may
       temporarily reduce the queue's effective rate. User-specified settings
       will not be changed.
    
      System throttling happens because:
    
       * Cloud Tasks backs off on all errors. Normally the backoff specified in
         [rate limits][google.cloud.tasks.v2.Queue.rate_limits] will be used. But
         if the worker returns `429` (Too Many Requests), `503` (Service
         Unavailable), or the rate of errors is high, Cloud Tasks will use a
         higher backoff rate. The retry specified in the `Retry-After` HTTP
         response header is considered.
    
       * To prevent traffic spikes and to smooth sudden increases in traffic,
         dispatches ramp up slowly when the queue is newly created or idle and
         if large numbers of tasks suddenly become available to dispatch (due to
         spikes in create task rates, the queue being unpaused, or many tasks
         that are scheduled at the same time).
     
    Protobuf type google.cloud.tasks.v2.HttpRequest
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  HttpRequest.AuthorizationHeaderCase  
      static class  HttpRequest.Builder
      HTTP request.
      • Nested classes/interfaces inherited from class com.google.protobuf.GeneratedMessageV3

        com.google.protobuf.GeneratedMessageV3.BuilderParent, com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageT extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>,​BuilderT extends com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageT,​BuilderT>>, com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>>, com.google.protobuf.GeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>>, com.google.protobuf.GeneratedMessageV3.FieldAccessorTable, com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter
      • Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite

        com.google.protobuf.AbstractMessageLite.InternalOneOfEnum
    • Method Detail

      • newInstance

        protected Object newInstance​(com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused)
        Overrides:
        newInstance in class com.google.protobuf.GeneratedMessageV3
      • getDescriptor

        public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
      • internalGetMapField

        protected com.google.protobuf.MapField internalGetMapField​(int number)
        Overrides:
        internalGetMapField in class com.google.protobuf.GeneratedMessageV3
      • internalGetFieldAccessorTable

        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
        Specified by:
        internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3
      • getUrl

        public String getUrl()
         Required. The full url path that the request will be sent to.
        
         This string must begin with either "http://" or "https://". Some examples
         are: `http://acme.com` and `https://acme.com/sales:8080`. Cloud Tasks will
         encode some characters for safety and compatibility. The maximum allowed
         URL length is 2083 characters after encoding.
        
         The `Location` header response from a redirect response [`300` - `399`]
         may be followed. The redirect is not counted as a separate attempt.
         
        string url = 1 [(.google.api.field_behavior) = REQUIRED];
        Specified by:
        getUrl in interface HttpRequestOrBuilder
        Returns:
        The url.
      • getUrlBytes

        public com.google.protobuf.ByteString getUrlBytes()
         Required. The full url path that the request will be sent to.
        
         This string must begin with either "http://" or "https://". Some examples
         are: `http://acme.com` and `https://acme.com/sales:8080`. Cloud Tasks will
         encode some characters for safety and compatibility. The maximum allowed
         URL length is 2083 characters after encoding.
        
         The `Location` header response from a redirect response [`300` - `399`]
         may be followed. The redirect is not counted as a separate attempt.
         
        string url = 1 [(.google.api.field_behavior) = REQUIRED];
        Specified by:
        getUrlBytes in interface HttpRequestOrBuilder
        Returns:
        The bytes for url.
      • getHttpMethodValue

        public int getHttpMethodValue()
         The HTTP method to use for the request. The default is POST.
         
        .google.cloud.tasks.v2.HttpMethod http_method = 2;
        Specified by:
        getHttpMethodValue in interface HttpRequestOrBuilder
        Returns:
        The enum numeric value on the wire for httpMethod.
      • getHttpMethod

        public HttpMethod getHttpMethod()
         The HTTP method to use for the request. The default is POST.
         
        .google.cloud.tasks.v2.HttpMethod http_method = 2;
        Specified by:
        getHttpMethod in interface HttpRequestOrBuilder
        Returns:
        The httpMethod.
      • getHeadersCount

        public int getHeadersCount()
        Description copied from interface: HttpRequestOrBuilder
         HTTP request headers.
        
         This map contains the header field names and values.
         Headers can be set when the
         [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
        
         These headers represent a subset of the headers that will accompany the
         task's HTTP request. Some HTTP request headers will be ignored or replaced.
        
         A partial list of headers that will be ignored or replaced is:
        
         * Host: This will be computed by Cloud Tasks and derived from
           [HttpRequest.url][google.cloud.tasks.v2.HttpRequest.url].
         * Content-Length: This will be computed by Cloud Tasks.
         * User-Agent: This will be set to `"Google-Cloud-Tasks"`.
         * `X-Google-*`: Google use only.
         * `X-AppEngine-*`: Google use only.
        
         `Content-Type` won't be set by Cloud Tasks. You can explicitly set
         `Content-Type` to a media type when the
          [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
          For example, `Content-Type` can be set to `"application/octet-stream"` or
          `"application/json"`.
        
         Headers which can have multiple values (according to RFC2616) can be
         specified using comma-separated values.
        
         The size of the headers must be less than 80KB.
         
        map<string, string> headers = 3;
        Specified by:
        getHeadersCount in interface HttpRequestOrBuilder
      • containsHeaders

        public boolean containsHeaders​(String key)
         HTTP request headers.
        
         This map contains the header field names and values.
         Headers can be set when the
         [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
        
         These headers represent a subset of the headers that will accompany the
         task's HTTP request. Some HTTP request headers will be ignored or replaced.
        
         A partial list of headers that will be ignored or replaced is:
        
         * Host: This will be computed by Cloud Tasks and derived from
           [HttpRequest.url][google.cloud.tasks.v2.HttpRequest.url].
         * Content-Length: This will be computed by Cloud Tasks.
         * User-Agent: This will be set to `"Google-Cloud-Tasks"`.
         * `X-Google-*`: Google use only.
         * `X-AppEngine-*`: Google use only.
        
         `Content-Type` won't be set by Cloud Tasks. You can explicitly set
         `Content-Type` to a media type when the
          [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
          For example, `Content-Type` can be set to `"application/octet-stream"` or
          `"application/json"`.
        
         Headers which can have multiple values (according to RFC2616) can be
         specified using comma-separated values.
        
         The size of the headers must be less than 80KB.
         
        map<string, string> headers = 3;
        Specified by:
        containsHeaders in interface HttpRequestOrBuilder
      • getHeadersMap

        public Map<String,​String> getHeadersMap()
         HTTP request headers.
        
         This map contains the header field names and values.
         Headers can be set when the
         [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
        
         These headers represent a subset of the headers that will accompany the
         task's HTTP request. Some HTTP request headers will be ignored or replaced.
        
         A partial list of headers that will be ignored or replaced is:
        
         * Host: This will be computed by Cloud Tasks and derived from
           [HttpRequest.url][google.cloud.tasks.v2.HttpRequest.url].
         * Content-Length: This will be computed by Cloud Tasks.
         * User-Agent: This will be set to `"Google-Cloud-Tasks"`.
         * `X-Google-*`: Google use only.
         * `X-AppEngine-*`: Google use only.
        
         `Content-Type` won't be set by Cloud Tasks. You can explicitly set
         `Content-Type` to a media type when the
          [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
          For example, `Content-Type` can be set to `"application/octet-stream"` or
          `"application/json"`.
        
         Headers which can have multiple values (according to RFC2616) can be
         specified using comma-separated values.
        
         The size of the headers must be less than 80KB.
         
        map<string, string> headers = 3;
        Specified by:
        getHeadersMap in interface HttpRequestOrBuilder
      • getHeadersOrDefault

        public String getHeadersOrDefault​(String key,
                                          String defaultValue)
         HTTP request headers.
        
         This map contains the header field names and values.
         Headers can be set when the
         [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
        
         These headers represent a subset of the headers that will accompany the
         task's HTTP request. Some HTTP request headers will be ignored or replaced.
        
         A partial list of headers that will be ignored or replaced is:
        
         * Host: This will be computed by Cloud Tasks and derived from
           [HttpRequest.url][google.cloud.tasks.v2.HttpRequest.url].
         * Content-Length: This will be computed by Cloud Tasks.
         * User-Agent: This will be set to `"Google-Cloud-Tasks"`.
         * `X-Google-*`: Google use only.
         * `X-AppEngine-*`: Google use only.
        
         `Content-Type` won't be set by Cloud Tasks. You can explicitly set
         `Content-Type` to a media type when the
          [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
          For example, `Content-Type` can be set to `"application/octet-stream"` or
          `"application/json"`.
        
         Headers which can have multiple values (according to RFC2616) can be
         specified using comma-separated values.
        
         The size of the headers must be less than 80KB.
         
        map<string, string> headers = 3;
        Specified by:
        getHeadersOrDefault in interface HttpRequestOrBuilder
      • getHeadersOrThrow

        public String getHeadersOrThrow​(String key)
         HTTP request headers.
        
         This map contains the header field names and values.
         Headers can be set when the
         [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
        
         These headers represent a subset of the headers that will accompany the
         task's HTTP request. Some HTTP request headers will be ignored or replaced.
        
         A partial list of headers that will be ignored or replaced is:
        
         * Host: This will be computed by Cloud Tasks and derived from
           [HttpRequest.url][google.cloud.tasks.v2.HttpRequest.url].
         * Content-Length: This will be computed by Cloud Tasks.
         * User-Agent: This will be set to `"Google-Cloud-Tasks"`.
         * `X-Google-*`: Google use only.
         * `X-AppEngine-*`: Google use only.
        
         `Content-Type` won't be set by Cloud Tasks. You can explicitly set
         `Content-Type` to a media type when the
          [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
          For example, `Content-Type` can be set to `"application/octet-stream"` or
          `"application/json"`.
        
         Headers which can have multiple values (according to RFC2616) can be
         specified using comma-separated values.
        
         The size of the headers must be less than 80KB.
         
        map<string, string> headers = 3;
        Specified by:
        getHeadersOrThrow in interface HttpRequestOrBuilder
      • getBody

        public com.google.protobuf.ByteString getBody()
         HTTP request body.
        
         A request body is allowed only if the
         [HTTP method][google.cloud.tasks.v2.HttpRequest.http_method] is POST, PUT,
         or PATCH. It is an error to set body on a task with an incompatible
         [HttpMethod][google.cloud.tasks.v2.HttpMethod].
         
        bytes body = 4;
        Specified by:
        getBody in interface HttpRequestOrBuilder
        Returns:
        The body.
      • hasOauthToken

        public boolean hasOauthToken()
         If specified, an
         [OAuth token](https://developers.google.com/identity/protocols/OAuth2)
         will be generated and attached as an `Authorization` header in the HTTP
         request.
        
         This type of authorization should generally only be used when calling
         Google APIs hosted on *.googleapis.com.
         
        .google.cloud.tasks.v2.OAuthToken oauth_token = 5;
        Specified by:
        hasOauthToken in interface HttpRequestOrBuilder
        Returns:
        Whether the oauthToken field is set.
      • getOauthToken

        public OAuthToken getOauthToken()
         If specified, an
         [OAuth token](https://developers.google.com/identity/protocols/OAuth2)
         will be generated and attached as an `Authorization` header in the HTTP
         request.
        
         This type of authorization should generally only be used when calling
         Google APIs hosted on *.googleapis.com.
         
        .google.cloud.tasks.v2.OAuthToken oauth_token = 5;
        Specified by:
        getOauthToken in interface HttpRequestOrBuilder
        Returns:
        The oauthToken.
      • getOauthTokenOrBuilder

        public OAuthTokenOrBuilder getOauthTokenOrBuilder()
         If specified, an
         [OAuth token](https://developers.google.com/identity/protocols/OAuth2)
         will be generated and attached as an `Authorization` header in the HTTP
         request.
        
         This type of authorization should generally only be used when calling
         Google APIs hosted on *.googleapis.com.
         
        .google.cloud.tasks.v2.OAuthToken oauth_token = 5;
        Specified by:
        getOauthTokenOrBuilder in interface HttpRequestOrBuilder
      • hasOidcToken

        public boolean hasOidcToken()
         If specified, an
         [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect)
         token will be generated and attached as an `Authorization` header in the
         HTTP request.
        
         This type of authorization can be used for many scenarios, including
         calling Cloud Run, or endpoints where you intend to validate the token
         yourself.
         
        .google.cloud.tasks.v2.OidcToken oidc_token = 6;
        Specified by:
        hasOidcToken in interface HttpRequestOrBuilder
        Returns:
        Whether the oidcToken field is set.
      • getOidcToken

        public OidcToken getOidcToken()
         If specified, an
         [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect)
         token will be generated and attached as an `Authorization` header in the
         HTTP request.
        
         This type of authorization can be used for many scenarios, including
         calling Cloud Run, or endpoints where you intend to validate the token
         yourself.
         
        .google.cloud.tasks.v2.OidcToken oidc_token = 6;
        Specified by:
        getOidcToken in interface HttpRequestOrBuilder
        Returns:
        The oidcToken.
      • getOidcTokenOrBuilder

        public OidcTokenOrBuilder getOidcTokenOrBuilder()
         If specified, an
         [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect)
         token will be generated and attached as an `Authorization` header in the
         HTTP request.
        
         This type of authorization can be used for many scenarios, including
         calling Cloud Run, or endpoints where you intend to validate the token
         yourself.
         
        .google.cloud.tasks.v2.OidcToken oidc_token = 6;
        Specified by:
        getOidcTokenOrBuilder in interface HttpRequestOrBuilder
      • isInitialized

        public final boolean isInitialized()
        Specified by:
        isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
        Overrides:
        isInitialized in class com.google.protobuf.GeneratedMessageV3
      • writeTo

        public void writeTo​(com.google.protobuf.CodedOutputStream output)
                     throws IOException
        Specified by:
        writeTo in interface com.google.protobuf.MessageLite
        Overrides:
        writeTo in class com.google.protobuf.GeneratedMessageV3
        Throws:
        IOException
      • getSerializedSize

        public int getSerializedSize()
        Specified by:
        getSerializedSize in interface com.google.protobuf.MessageLite
        Overrides:
        getSerializedSize in class com.google.protobuf.GeneratedMessageV3
      • equals

        public boolean equals​(Object obj)
        Specified by:
        equals in interface com.google.protobuf.Message
        Overrides:
        equals in class com.google.protobuf.AbstractMessage
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface com.google.protobuf.Message
        Overrides:
        hashCode in class com.google.protobuf.AbstractMessage
      • parseFrom

        public static HttpRequest parseFrom​(ByteBuffer data)
                                     throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static HttpRequest parseFrom​(ByteBuffer data,
                                            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                     throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static HttpRequest parseFrom​(com.google.protobuf.ByteString data)
                                     throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static HttpRequest parseFrom​(com.google.protobuf.ByteString data,
                                            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                     throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static HttpRequest parseFrom​(byte[] data)
                                     throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static HttpRequest parseFrom​(byte[] data,
                                            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                     throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static HttpRequest parseFrom​(com.google.protobuf.CodedInputStream input,
                                            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                     throws IOException
        Throws:
        IOException
      • newBuilderForType

        public HttpRequest.Builder newBuilderForType()
        Specified by:
        newBuilderForType in interface com.google.protobuf.Message
        Specified by:
        newBuilderForType in interface com.google.protobuf.MessageLite
      • toBuilder

        public HttpRequest.Builder toBuilder()
        Specified by:
        toBuilder in interface com.google.protobuf.Message
        Specified by:
        toBuilder in interface com.google.protobuf.MessageLite
      • newBuilderForType

        protected HttpRequest.Builder newBuilderForType​(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)
        Specified by:
        newBuilderForType in class com.google.protobuf.GeneratedMessageV3
      • getDefaultInstance

        public static HttpRequest getDefaultInstance()
      • parser

        public static com.google.protobuf.Parser<HttpRequest> parser()
      • getParserForType

        public com.google.protobuf.Parser<HttpRequest> getParserForType()
        Specified by:
        getParserForType in interface com.google.protobuf.Message
        Specified by:
        getParserForType in interface com.google.protobuf.MessageLite
        Overrides:
        getParserForType in class com.google.protobuf.GeneratedMessageV3
      • getDefaultInstanceForType

        public HttpRequest getDefaultInstanceForType()
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuilder
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilder