Interface HttpPipelinePolicyChain
-
public interface HttpPipelinePolicyChainThe type that enablesHttpPipelinePolicyimplementations to access theHttpRequestand the correspondingHttpResponseflowing through the pipeline.Additionally policy implementations uses
HttpPipelinePolicyChainto:- 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 voidcompleted(HttpResponse response)Signal that the policy execution is successfully completed.voidcompletedError(java.lang.Throwable error)Signal that the policy execution is completed with failure.com.azure.android.core.util.CancellationTokengetCancellationToken()Gets theCancellationTokenassociated with the pipeline run.com.azure.android.core.util.RequestContextgetContext()Gets the context that was given toHttpPipeline.send(HttpRequest, RequestContext, CancellationToken, HttpCallback)call, the send call that initiated the pipeline run.HttpRequestgetRequest()Gets theHttpRequestfor the policy too intercept.voidprocessNextPolicy(HttpRequest request)Signal that the pipeline can proceed with the execution of the next policy.voidprocessNextPolicy(HttpRequest request, NextPolicyCallback callback)Signal that the pipeline can proceed with the execution of the next policy.voidprocessNextPolicy(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 theHttpRequestfor the policy too intercept.- Returns:
- The HTTP request object.
-
getCancellationToken
com.azure.android.core.util.CancellationToken getCancellationToken()
Gets theCancellationTokenassociated 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 theHttpResponseor 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 theHttpResponseor 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.
-
-