public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
{
if (NetEventSource.IsEnabled)
{
NetEventSource.Enter(this);
NetEventSource.Info(this, $"Method: {_methodInfo.Method}");
}
ContextAwareResult asyncResult = null;
try
{
if (_getRequestStreamStarted)
{
throw new InvalidOperationException(SR.net_repcall);
}
_getRequestStreamStarted = true;
if (!_methodInfo.IsUpload)
{
throw new ProtocolViolationException(SR.net_nouploadonget);
}
CheckError();
FinishRequestStage(RequestStage.RequestStarted);
asyncResult = new ContextAwareResult(true, true, this, state, callback);
lock (asyncResult.StartPostingAsyncOp())
{
_writeAsyncResult = asyncResult;
SubmitRequest(true);
asyncResult.FinishPostingAsyncOp();
FinishRequestStage(RequestStage.CheckForError);
}
}
catch (Exception exception)
{
if (NetEventSource.IsEnabled) NetEventSource.Error(this, exception);
throw;
}
finally
{
if (NetEventSource.IsEnabled) NetEventSource.Exit(this);
}
return asyncResult;
}