Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #14 from microsoft/downgradePackages
Browse files Browse the repository at this point in the history
Changes target runtime to netstandard2.0
  • Loading branch information
baywet authored Apr 12, 2022
2 parents a54d08d + c858e2a commit 7148aca
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

## [1.0.0-preview.6] - 2022-04-12

### Changed

- Breaking: Changes target runtime to netstandard2.0

## [1.0.0-preview.5] - 2022-04-07

### Added
Expand Down
17 changes: 9 additions & 8 deletions src/Extensions/HttpRequestMessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------

using System.Collections.Generic;
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Kiota.Abstractions;
using Microsoft.Kiota.Abstractions.Extensions;

namespace Microsoft.Kiota.Http.HttpClientLibrary.Extensions
{
Expand Down Expand Up @@ -45,12 +46,12 @@ internal static async Task<HttpRequestMessage> CloneAsync(this HttpRequestMessag
var newRequest = new HttpRequestMessage(originalRequest.Method, originalRequest.RequestUri);

// Copy request headers.
foreach(var (key, value) in originalRequest.Headers)
newRequest.Headers.TryAddWithoutValidation(key, value);
foreach(var header in originalRequest.Headers)
newRequest.Headers.TryAddWithoutValidation(header.Key, header.Value);

// Copy request properties.
foreach(var (key, value) in originalRequest.Properties)
newRequest.Properties.TryAdd(key, value);
foreach(var property in originalRequest.Properties)
newRequest.Properties.TryAdd(property.Key, property.Value);

// Set Content if previous request had one.
if(originalRequest.Content != null)
Expand All @@ -64,9 +65,9 @@ internal static async Task<HttpRequestMessage> CloneAsync(this HttpRequestMessag
newRequest.Content = new StreamContent(contentStream);

// Copy content headers.
foreach(var (key, value) in originalRequest.Content.Headers)
foreach(var header in originalRequest.Content.Headers)
{
newRequest.Content?.Headers.TryAddWithoutValidation(key, value);
newRequest.Content?.Headers.TryAddWithoutValidation(header.Key, header.Value);
}
}

Expand All @@ -82,7 +83,7 @@ internal static bool IsBuffered(this HttpRequestMessage httpRequestMessage)
{
HttpContent requestContent = httpRequestMessage.Content;

if((httpRequestMessage.Method == HttpMethod.Put || httpRequestMessage.Method == HttpMethod.Post || httpRequestMessage.Method == HttpMethod.Patch)
if((httpRequestMessage.Method == HttpMethod.Put || httpRequestMessage.Method == HttpMethod.Post || httpRequestMessage.Method.Method.Equals("PATCH", StringComparison.OrdinalIgnoreCase))
&& requestContent != null && (requestContent.Headers.ContentLength == null || (int)requestContent.Headers.ContentLength == -1))
{
return false;
Expand Down
7 changes: 4 additions & 3 deletions src/HttpClientRequestAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.Kiota.Abstractions.Authentication;
using System.Threading;
using System.Net;
using Microsoft.Kiota.Abstractions.Extensions;

namespace Microsoft.Kiota.Http.HttpClientLibrary
{
Expand Down Expand Up @@ -331,9 +332,9 @@ public HttpRequestMessage GetRequestMessageFromRequestInformation(RequestInforma
if(requestInfo.Content != null)
message.Content = new StreamContent(requestInfo.Content);
if(requestInfo.Headers?.Any() ?? false)
foreach(var (key,value) in requestInfo.Headers)
if(!message.Headers.TryAddWithoutValidation(key, value) && message.Content != null)
message.Content.Headers.TryAddWithoutValidation(key, value);// Try to add the headers we couldn't add to the HttpRequestMessage before to the HttpContent
foreach(var header in requestInfo.Headers)
if(!message.Headers.TryAddWithoutValidation(header.Key, header.Value) && message.Content != null)
message.Content.Headers.TryAddWithoutValidation(header.Key, header.Value);// Try to add the headers we couldn't add to the HttpRequestMessage before to the HttpContent

return message;
}
Expand Down
2 changes: 1 addition & 1 deletion src/KiotaClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static DelegatingHandler ChainHandlersCollectionAndGetFirstLink(HttpMessa
}
}
if(finalHandler != null)
handlers[^1].InnerHandler = finalHandler;
handlers[handlers.Length-1].InnerHandler = finalHandler;
return handlers.First();
}
/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.Kiota.Http.HttpClientLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<AssemblyTitle>Kiota Http Library for dotnet</AssemblyTitle>
<Authors>Microsoft</Authors>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/microsoft/kiota-http-dotnet</RepositoryUrl>
<PackageProjectUrl>https://microsoft.github.io/kiota/</PackageProjectUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>preview.5</VersionSuffix>
<VersionSuffix>preview.6</VersionSuffix>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<!-- Enable this line once we go live to prevent breaking changes -->
<!-- <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> -->
<SignAssembly>false</SignAssembly>
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<PackageReleaseNotes>
- Added supports for decoding parameter names.
- Breaking: Changes target runtime to netstandard2.0
</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
Expand All @@ -31,7 +31,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.0.0-preview.4" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.0.0-preview.5" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.2" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/ChaosHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static HttpResponseMessage Create429TooManyRequestsResponse(TimeSpan retr
});
var throttleResponse = new HttpResponseMessage
{
StatusCode = HttpStatusCode.TooManyRequests,
StatusCode = (HttpStatusCode)429,
Content = new StringContent(contentString, Encoding.UTF8, Json)
};
throttleResponse.Headers.RetryAfter = new RetryConditionHeaderValue(retry);
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/RetryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private static bool ShouldRetry(HttpStatusCode statusCode)
{
HttpStatusCode.ServiceUnavailable => true,
HttpStatusCode.GatewayTimeout => true,
HttpStatusCode.TooManyRequests => true,
(HttpStatusCode)429 => true,
_ => false
};
}
Expand Down

0 comments on commit 7148aca

Please sign in to comment.