PipelineTransport
Represents an HTTP pipeline transport used to send and receive HTTP requests
and responses.
using System.ClientModel.Internal;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace System.ClientModel.Primitives
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public abstract class PipelineTransport : PipelinePolicy
{
public PipelineMessage CreateMessage()
{
PipelineMessage pipelineMessage;
PipelineMessage pipelineMessage2 = pipelineMessage = CreateMessageCore();
TimeSpan? networkTimeout = pipelineMessage.NetworkTimeout;
TimeSpan valueOrDefault = networkTimeout.GetValueOrDefault();
if (!networkTimeout.HasValue) {
valueOrDefault = ClientPipeline.DefaultNetworkTimeout;
TimeSpan? nullable2 = pipelineMessage.NetworkTimeout = valueOrDefault;
}
if (pipelineMessage2.Request == null)
throw new InvalidOperationException("Request was not set on message.");
if (pipelineMessage2.Response != null)
throw new InvalidOperationException("Response should not be set before transport is invoked.");
return pipelineMessage2;
}
protected abstract PipelineMessage CreateMessageCore();
public void Process(PipelineMessage message)
{
ProcessSyncOrAsync(message, false).EnsureCompleted();
}
[AsyncStateMachine(typeof(<ProcessAsync>d__3))]
public ValueTask ProcessAsync(PipelineMessage message)
{
<ProcessAsync>d__3 stateMachine = default(<ProcessAsync>d__3);
stateMachine.<>t__builder = AsyncValueTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.message = message;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<ProcessSyncOrAsync>d__4))]
private ValueTask ProcessSyncOrAsync(PipelineMessage message, bool async)
{
<ProcessSyncOrAsync>d__4 stateMachine = default(<ProcessSyncOrAsync>d__4);
stateMachine.<>t__builder = AsyncValueTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.message = message;
stateMachine.async = async;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
protected abstract void ProcessCore(PipelineMessage message);
protected abstract ValueTask ProcessCoreAsync(PipelineMessage message);
private static bool ClassifyResponse(PipelineMessage message)
{
if (!message.ResponseClassifier.TryClassify(message, out bool isError))
PipelineMessageClassifier.Default.TryClassify(message, out isError);
return isError;
}
public sealed override void Process(PipelineMessage message, IReadOnlyList<PipelinePolicy> pipeline, int currentIndex)
{
Process(message);
}
[AsyncStateMachine(typeof(<ProcessAsync>d__9))]
public sealed override ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList<PipelinePolicy> pipeline, int currentIndex)
{
<ProcessAsync>d__9 stateMachine = default(<ProcessAsync>d__9);
stateMachine.<>t__builder = AsyncValueTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.message = message;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
}
}