Interface HttpPipelinePolicyChain


  • public interface HttpPipelinePolicyChain
    The type that enables HttpPipelinePolicy implementations to access the HttpRequest and the corresponding HttpResponse flowing through the pipeline.

    Additionally policy implementations uses HttpPipelinePolicyChain to:

    • signal the completion of request-response interception.
    • check whether the http call is cancelled.

    • Method Detail

      • getRequest

        HttpRequest getRequest()
        Gets the HttpRequest for the policy too intercept.
        Returns:
        The HTTP request object.
      • getCancellationToken

        com.azure.android.core.util.CancellationToken getCancellationToken()
        Gets the CancellationToken associated with the pipeline run.

        In policy implementation, before starting any potentially time and resource-consuming work, it is recommended to check CancellationToken.isCancellationRequested() to see that the user expressed lost interest in the result; if so, the implementation can finish the execution by calling HttpPipelinePolicyChain#finishedProcessing(new IOException("Canceled.")).

        Returns:
        The cancellation token.
      • getContext

        com.azure.android.core.util.RequestContext getContext()
        Gets the context that was given to HttpPipeline.send(HttpRequest, RequestContext, CancellationToken, HttpCallback) call, the send call that initiated the pipeline run.

        The policy implementation may inspect the context for any known settings specific to the policy. If the policy calls into Azure SDK API that accept context, then this context or a new immutable context object obtained by calling the RequestContext.addData(Object, Object) on this context should be provided to the API.

        Returns:
        The context.
      • processNextPolicy

        void processNextPolicy​(HttpRequest request)
        Signal that the pipeline can proceed with the execution of the next policy.

        A policy implementation calls this method to indicate its completion of request interception and to signal that the next policy can be executed.

        Parameters:
        request - The HTTP Request.
      • processNextPolicy

        void processNextPolicy​(HttpRequest request,
                               NextPolicyCallback callback)
        Signal that the pipeline can proceed with the execution of the next policy.

        A policy implementation calls this method to indicate its completion of request interception and to signal that the next policy can be executed.

        Parameters:
        request - The HTTP Request.
        callback - The callback to receive the HttpResponse or the error from the next policy once its completes the execution.
      • processNextPolicy

        void processNextPolicy​(HttpRequest request,
                               NextPolicyCallback callback,
                               long delay,
                               java.util.concurrent.TimeUnit timeUnit)
        Signal that, after the specified delay the pipeline can proceed with the execution of the next policy.

        A policy implementation calls this method to indicate its completion of request interception and to signal that the next policy can be executed.

        Parameters:
        request - The HTTP Request.
        callback - The callback to receive the HttpResponse or the error from the next policy once its completes the execution.
        delay - The time from now to delay the execution of next policy.
        timeUnit - The time unit of the delay.
      • completed

        void completed​(HttpResponse response)
        Signal that the policy execution is successfully completed.

        A policy implementation calls this method to indicate its completion of response interception and to signal that response should be given to the previous policy in the pipeline.

        Parameters:
        response - The HTTP Response.
      • completedError

        void completedError​(java.lang.Throwable error)
        Signal that the policy execution is completed with failure.

        A policy implementation calls this method to signal that its execution is failed and the failure should be propagated to the previous policy in the pipeline.

        Parameters:
        error - The failure.