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

Fix HttpClientRequestMessage.cs #43

Merged
merged 9 commits into from
Aug 14, 2020
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Target Name="SetNuspecProperties" BeforeTargets="GenerateNuspec">
<PropertyGroup>
<NuspecProperties>ProductRoot=$(productBinPath);version=$(VERSION_SEMANITCS_CLIENT_ABSTRACTIONS)</NuspecProperties>
<NuspecProperties>$(NuspecProperties);ODataClientPackageDependency=7.6.0</NuspecProperties>
<NuspecProperties>$(NuspecProperties);ODataClientPackageDependency=7.7.0</NuspecProperties>
</PropertyGroup>
</Target>
<Import Project="..\Build.props" />
Expand All @@ -18,6 +18,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.OData.Client" Version="7.6.0" />
<PackageReference Include="Microsoft.OData.Client" Version="7.7.0" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//---------------------------------------------------------------------
//---------------------------------------------------------------------
// <copyright file="HttpClientRequestMessage.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation and Contributors. All rights reserved. See License.txt in the project root for license information.
// </copyright>
Expand Down Expand Up @@ -150,6 +150,51 @@ public override ICredentials Credentials
this.requestMessage.Properties[typeof(ICredentials).FullName] = value;
}
}

/// <summary>
/// Gets or sets the timeout (in seconds) for this request.
/// </summary>
public override int Timeout
{
get
{
return (int)this.client.Timeout.TotalSeconds;
}
set
{
this.client.Timeout = new TimeSpan(0, 0, value);
}
}

public override int ReadWriteTimeout
{
get
{
return (int)this.client.Timeout.TotalSeconds;
}
set
{
this.client.Timeout = new TimeSpan(0, 0, value);
}
}

#if !(NETCOREAPP1_0 || NETCOREAPP2_0)
/// <summary>
/// Gets or sets a value that indicates whether to send data in segments to the Internet resource.
/// </summary>
public override bool SendChunked
{
get
{
bool? transferEncodingChunked = this.requestMessage.Headers.TransferEncodingChunked;
return transferEncodingChunked.HasValue && transferEncodingChunked.Value;
}
set
{
this.requestMessage.Headers.TransferEncodingChunked = value;
}
}
#endif

/// <summary>
/// Returns the value of the header with the given name.
Expand Down Expand Up @@ -254,6 +299,18 @@ public override IODataResponseMessage EndGetResponse(IAsyncResult asyncResult)
{
return UnwrapAggregateException(() => new HttpClientResponseMessage(((Task<HttpResponseMessage>)asyncResult).Result, this.config));
}

#if !(NETCOREAPP1_0 || NETCOREAPP2_0)
public override IODataResponseMessage GetResponse()
{
return UnwrapAggregateException(() =>
{
var send = CreateSendTask();
send.Wait();
return new HttpClientResponseMessage(send.Result, this.config);
});
}
#endif

/// <summary>
/// Dispose the object.
Expand Down Expand Up @@ -313,4 +370,4 @@ private static DataServiceTransportException ConvertToDataServiceWebException(We
return new DataServiceTransportException(errorResponseMessage, webException);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.OData.Client" Version="7.6.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" />
<PackageReference Include="Microsoft.OData.Client" Version="7.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="FluentAssertions" Version="4.19.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.OData.Client" Version="7.6.0" />
<PackageReference Include="Microsoft.OData.Client" Version="7.7.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
Expand All @@ -35,4 +35,4 @@
</None>
</ItemGroup>

</Project>
</Project>