Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squashed commit of Master merge to release/2.1.0 #2740

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,11 @@ public async Task SendRequestAsync(Message message, TimeoutHelper timeoutHelper)
_timeoutHelper = timeoutHelper;
_factory.ApplyManualAddressing(ref _to, ref _via, message);
_httpClient = await _channel.GetHttpClientAsync(_to, _via, _timeoutHelper);
_httpRequestMessage = _channel.GetHttpRequestMessage(_via);

// The _httpRequestMessage field will be set to null by Cleanup() due to faulting
// or aborting, so use a local copy for exception handling within this method.
HttpRequestMessage httpRequestMessage = _httpRequestMessage;
HttpRequestMessage httpRequestMessage = _channel.GetHttpRequestMessage(_via);
_httpRequestMessage = httpRequestMessage;
Message request = message;

try
Expand All @@ -1033,7 +1033,7 @@ public async Task SendRequestAsync(Message message, TimeoutHelper timeoutHelper)

if (!suppressEntityBody)
{
_httpRequestMessage.Content = MessageContent.Create(_factory, request, _timeoutHelper);
httpRequestMessage.Content = MessageContent.Create(_factory, request, _timeoutHelper);
}

try
Expand All @@ -1052,13 +1052,13 @@ public async Task SendRequestAsync(Message message, TimeoutHelper timeoutHelper)
{
using (timeoutToken.Register(s_cancelCts, _httpSendCts))
{
_httpResponseMessage = await _httpClient.SendAsync(_httpRequestMessage, HttpCompletionOption.ResponseHeadersRead, _httpSendCts.Token);
_httpResponseMessage = await _httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseHeadersRead, _httpSendCts.Token);
}

// As we have the response message and no exceptions have been thrown, the request message has completed it's job.
// Calling Dispose() on the request message to free up resources in HttpContent, but keeping the object around
// as we can still query properties once dispose'd.
_httpRequestMessage.Dispose();
httpRequestMessage.Dispose();
success = true;
}
catch (HttpRequestException requestException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,26 +511,26 @@ private void ThrowIfClosed()
private Exception ConvertSendException(SocketException socketException, TimeSpan remainingTime)
{
return ConvertTransferException(socketException, _sendTimeout, socketException,
TransferOperation.Write, _aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime);
_aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime);
}

private Exception ConvertReceiveException(SocketException socketException, TimeSpan remainingTime)
{
return ConvertTransferException(socketException, _receiveTimeout, socketException,
TransferOperation.Read, _aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime);
_aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime);
}

internal static Exception ConvertTransferException(SocketException socketException, TimeSpan timeout, Exception originalException)
{
return ConvertTransferException(socketException, timeout, originalException,
TransferOperation.Undefined, false, null, TransferOperation.Undefined, null, TimeSpan.MaxValue);
false, null, TransferOperation.Undefined, null, TimeSpan.MaxValue);
}

private Exception ConvertObjectDisposedException(ObjectDisposedException originalException, TransferOperation transferOperation)
{
if (_timeoutErrorString != null)
{
return ConvertTimeoutErrorException(originalException, transferOperation, _timeoutErrorString, _timeoutErrorTransferOperation);
return ConvertTimeoutErrorException(originalException, _timeoutErrorString, _timeoutErrorTransferOperation);
}
else if (_aborted)
{
Expand All @@ -543,7 +543,7 @@ private Exception ConvertObjectDisposedException(ObjectDisposedException origina
}

private static Exception ConvertTransferException(SocketException socketException, TimeSpan timeout, Exception originalException,
TransferOperation transferOperation, bool aborted, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation,
bool aborted, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation,
SocketConnection socketConnection, TimeSpan remainingTime)
{
if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.ERROR_INVALID_HANDLE)
Expand All @@ -553,7 +553,7 @@ private static Exception ConvertTransferException(SocketException socketExceptio

if (timeoutErrorString != null)
{
return ConvertTimeoutErrorException(originalException, transferOperation, timeoutErrorString, timeoutErrorTransferOperation);
return ConvertTimeoutErrorException(originalException, timeoutErrorString, timeoutErrorTransferOperation);
}

// 10053 can occur due to our timeout sockopt firing, so map to TimeoutException in that case
Expand Down Expand Up @@ -597,12 +597,11 @@ private static Exception ConvertTransferException(SocketException socketExceptio
}
}

private static Exception ConvertTimeoutErrorException(Exception originalException,
TransferOperation transferOperation, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation)
private static Exception ConvertTimeoutErrorException(Exception originalException, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation)
{
Contract.Assert(timeoutErrorString != null, "Argument timeoutErrorString must not be null.");

if (transferOperation == timeoutErrorTransferOperation)
if (timeoutErrorTransferOperation != TransferOperation.Undefined)
{
return new TimeoutException(timeoutErrorString, originalException);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

public partial class Tcp_ClientCredentialTypeTests : ConditionalWcfTest
{
// See dotnet/wcf#2738 if failing with: System.InvalidOperationException : The client certificate could not be installed
[WcfFact]
[Condition(nameof(Root_Certificate_Installed), nameof(Client_Certificate_Installed))]
[OuterLoop]
Expand Down Expand Up @@ -60,6 +61,7 @@ public static void TcpClientCredentialType_Certificate_EchoString()
}
}

// See dotnet/wcf#2738 if failing with: System.InvalidOperationException : The client certificate could not be installed
[WcfFact]
[Condition(nameof(Root_Certificate_Installed), nameof(Client_Certificate_Installed))]
[OuterLoop]
Expand Down