-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt http/special-headers/conditional-request from cadl ranch (#5318)
Fixes #3990 cherry picked from @nisha-bhatia 's [PR](#5214) for clarity. But this requires the update in that PR to work properly. --------- Co-authored-by: nisha-bhatia <[email protected]>
- Loading branch information
1 parent
7ad5e77
commit 9bc1675
Showing
9 changed files
with
459 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../CadlRanch.Tests/Http/SpecialHeaders/ConditionalRequests/ConditionalRequestHeaderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using SpecialHeaders.ConditionalRequest; | ||
using TestProjects.CadlRanch.Tests; | ||
|
||
namespace CadlRanchProjects.Tests.Http.SpecialHeaders.ConditionalRequests | ||
{ | ||
public class ConditionalRequestHeaderTests : CadlRanchTestBase | ||
{ | ||
[CadlRanchTest] | ||
public Task Special_Headers_Conditional_Request_PostIfMatch() => Test(async (host) => | ||
{ | ||
string ifMatch = new string("valid"); | ||
var response = await new ConditionalRequestClient(host, null).PostIfMatchAsync(ifMatch); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task Special_Headers_Conditional_Request_PostIfNoneMatch() => Test(async (host) => | ||
{ | ||
string ifNoneMatch = new string("invalid"); | ||
var response = await new ConditionalRequestClient(host, null).PostIfNoneMatchAsync(ifNoneMatch); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task Special_Headers_Conditional_Request_HeadIfModifiedSince() => Test(async (host) => | ||
{ | ||
DateTimeOffset ifModifiedSince = DateTimeOffset.Parse("Fri, 26 Aug 2022 14:38:00 GMT"); | ||
var response = await new ConditionalRequestClient(host, null).HeadIfModifiedSinceAsync(ifModifiedSince); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task Special_Headers_Conditional_Request_PostIfUnmodifiedSince() => Test(async (host) => | ||
{ | ||
DateTimeOffset ifUnmodifiedSince = DateTimeOffset.Parse("Fri, 26 Aug 2022 14:38:00 GMT"); | ||
var response = await new ConditionalRequestClient(host, null).HeadIfModifiedSinceAsync(ifUnmodifiedSince); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...erator/TestProjects/CadlRanch/http/special-headers/conditional-request/Configuration.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"output-folder": ".", | ||
"namespace": "SpecialHeaders.ConditionalRequest", | ||
"library-name": "SpecialHeaders.ConditionalRequest", | ||
"use-model-reader-writer": true | ||
} |
48 changes: 48 additions & 0 deletions
48
.../CadlRanch/http/special-headers/conditional-request/SpecialHeaders.ConditionalRequest.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29709.97 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpecialHeaders.ConditionalRequest", "src\SpecialHeaders.ConditionalRequest.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} | ||
EndGlobalSection | ||
EndGlobal |
53 changes: 53 additions & 0 deletions
53
...lRanch/http/special-headers/conditional-request/src/Generated/ConditionalRequestClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// <auto-generated/> | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.ClientModel; | ||
using System.ClientModel.Primitives; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace SpecialHeaders.ConditionalRequest | ||
{ | ||
public partial class ConditionalRequestClient | ||
{ | ||
public ConditionalRequestClient() : this(new Uri("http://localhost:3000"), new ConditionalRequestClientOptions()) => throw null; | ||
|
||
public ConditionalRequestClient(Uri endpoint, ConditionalRequestClientOptions options) => throw null; | ||
|
||
public ClientPipeline Pipeline => throw null; | ||
|
||
public virtual ClientResult PostIfMatch(string ifMatch, RequestOptions options) => throw null; | ||
|
||
public virtual Task<ClientResult> PostIfMatchAsync(string ifMatch, RequestOptions options) => throw null; | ||
|
||
public virtual ClientResult PostIfMatch(string ifMatch = null, CancellationToken cancellationToken = default) => throw null; | ||
|
||
public virtual Task<ClientResult> PostIfMatchAsync(string ifMatch = null, CancellationToken cancellationToken = default) => throw null; | ||
|
||
public virtual ClientResult PostIfNoneMatch(string ifNoneMatch, RequestOptions options) => throw null; | ||
|
||
public virtual Task<ClientResult> PostIfNoneMatchAsync(string ifNoneMatch, RequestOptions options) => throw null; | ||
|
||
public virtual ClientResult PostIfNoneMatch(string ifNoneMatch = null, CancellationToken cancellationToken = default) => throw null; | ||
|
||
public virtual Task<ClientResult> PostIfNoneMatchAsync(string ifNoneMatch = null, CancellationToken cancellationToken = default) => throw null; | ||
|
||
public virtual ClientResult HeadIfModifiedSince(DateTimeOffset? ifModifiedSince, RequestOptions options) => throw null; | ||
|
||
public virtual Task<ClientResult> HeadIfModifiedSinceAsync(DateTimeOffset? ifModifiedSince, RequestOptions options) => throw null; | ||
|
||
public virtual ClientResult HeadIfModifiedSince(DateTimeOffset? ifModifiedSince = null, CancellationToken cancellationToken = default) => throw null; | ||
|
||
public virtual Task<ClientResult> HeadIfModifiedSinceAsync(DateTimeOffset? ifModifiedSince = null, CancellationToken cancellationToken = default) => throw null; | ||
|
||
public virtual ClientResult PostIfUnmodifiedSince(DateTimeOffset? ifUnmodifiedSince, RequestOptions options) => throw null; | ||
|
||
public virtual Task<ClientResult> PostIfUnmodifiedSinceAsync(DateTimeOffset? ifUnmodifiedSince, RequestOptions options) => throw null; | ||
|
||
public virtual ClientResult PostIfUnmodifiedSince(DateTimeOffset? ifUnmodifiedSince = null, CancellationToken cancellationToken = default) => throw null; | ||
|
||
public virtual Task<ClientResult> PostIfUnmodifiedSinceAsync(DateTimeOffset? ifUnmodifiedSince = null, CancellationToken cancellationToken = default) => throw null; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...http/special-headers/conditional-request/src/Generated/ConditionalRequestClientOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// <auto-generated/> | ||
|
||
#nullable disable | ||
|
||
using System.ClientModel.Primitives; | ||
|
||
namespace SpecialHeaders.ConditionalRequest | ||
{ | ||
public partial class ConditionalRequestClientOptions : ClientPipelineOptions | ||
{ | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...nch/http/special-headers/conditional-request/src/SpecialHeaders.ConditionalRequest.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Description>This is the SpecialHeaders.ConditionalRequest client library for developing .NET applications with rich experience.</Description> | ||
<AssemblyTitle>SDK Code Generation SpecialHeaders.ConditionalRequest</AssemblyTitle> | ||
<Version>1.0.0-beta.1</Version> | ||
<PackageTags>SpecialHeaders.ConditionalRequest</PackageTags> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<LangVersion>latest</LangVersion> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.ClientModel" Version="1.1.0-beta.4" /> | ||
<PackageReference Include="System.Text.Json" Version="8.0.5" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.