Interface HttpPipelinePolicyChain
-
public interface HttpPipelinePolicyChain
The type that enablesHttpPipelinePolicy
implementations to access theHttpRequest
and the correspondingHttpResponse
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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
completed(HttpResponse response)
Signal that the policy execution is successfully completed.void
completedError(java.lang.Throwable error)
Signal that the policy execution is completed with failure.com.azure.android.core.util.CancellationToken
getCancellationToken()
Gets theCancellationToken
associated with the pipeline run.com.azure.android.core.util.RequestContext
getContext()
Gets the context that was given toHttpPipeline.send(HttpRequest, RequestContext, CancellationToken, HttpCallback)
call, the send call that initiated the pipeline run.HttpRequest
getRequest()
Gets theHttpRequest
for the policy too intercept.void
processNextPolicy(HttpRequest request)
Signal that the pipeline can proceed with the execution of the next policy.void
processNextPolicy(HttpRequest request, NextPolicyCallback callback)
Signal that the pipeline can proceed with the execution of the next policy.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.
-
-
-
Method Detail
-
getRequest
HttpRequest getRequest()
Gets theHttpRequest
for the policy too intercept.- Returns:
- The HTTP request object.
-
getCancellationToken
com.azure.android.core.util.CancellationToken getCancellationToken()
Gets theCancellationToken
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 callingHttpPipelinePolicyChain#finishedProcessing(new IOException("Canceled."))
.- Returns:
- The cancellation token.
-
getContext
com.azure.android.core.util.RequestContext getContext()
Gets the context that was given toHttpPipeline.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 theHttpResponse
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 theHttpResponse
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 thedelay
.
-
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.
-
-