Add header formatting support (#313)
This commit is contained in:
Родитель
27ec5a8091
Коммит
f07c86cbae
|
@ -8,7 +8,7 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
{
|
||||
internal class ClientMethodRequest
|
||||
{
|
||||
public ClientMethodRequest(RequestMethod method, ConstantOrParameter[] hostSegments, PathSegment[] pathSegments, QueryParameter[] query, KeyValuePair<string, ConstantOrParameter>[] headers, int[] successfulStatusCodes, ConstantOrParameter? body)
|
||||
public ClientMethodRequest(RequestMethod method, ConstantOrParameter[] hostSegments, PathSegment[] pathSegments, QueryParameter[] query, RequestHeader[] headers, int[] successfulStatusCodes, ConstantOrParameter? body)
|
||||
{
|
||||
Method = method;
|
||||
HostSegments = hostSegments;
|
||||
|
@ -23,7 +23,7 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
public ConstantOrParameter[] HostSegments { get; }
|
||||
public PathSegment[] PathSegments { get; }
|
||||
public QueryParameter[] Query { get; }
|
||||
public KeyValuePair<string, ConstantOrParameter>[] Headers { get; }
|
||||
public RequestHeader[] Headers { get; }
|
||||
public int[] SuccessfulStatusCodes { get; set; }
|
||||
public ConstantOrParameter? Body { get; set; }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
namespace AutoRest.CSharp.V3.ClientModels
|
||||
{
|
||||
internal enum HeaderSerializationFormat
|
||||
{
|
||||
Default,
|
||||
DateTimeRFC1123,
|
||||
DateTimeISO8601,
|
||||
Date
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
namespace AutoRest.CSharp.V3.ClientModels
|
||||
{
|
||||
internal class RequestHeader
|
||||
{
|
||||
public string Name { get; }
|
||||
public ConstantOrParameter Value { get; }
|
||||
public HeaderSerializationFormat Format { get; }
|
||||
|
||||
public RequestHeader(string name, ConstantOrParameter value, HeaderSerializationFormat format = HeaderSerializationFormat.Default)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
Format = format;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -95,19 +95,28 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
: $"request.Uri.AppendPath({value.Parameter.Name}.ToString()!, {segment.Escape.ToString().ToLower()});");
|
||||
}
|
||||
|
||||
foreach (var pair in operation.Request.Headers)
|
||||
foreach (var header in operation.Request.Headers)
|
||||
{
|
||||
if (pair.Value.IsConstant)
|
||||
if (header.Value.IsConstant)
|
||||
{
|
||||
Line($"request.Headers.Add(\"{pair.Key}\", \"{pair.Value.Constant.Value}\");");
|
||||
Line($"request.Headers.Add(\"{header.Name}\", \"{header.Value.Constant.Value}\");");
|
||||
continue;
|
||||
}
|
||||
|
||||
var parameter = pair.Value.Parameter;
|
||||
using (parameter.Type.IsNullable ? If($"{parameter.Name} != null") : new DisposeAction())
|
||||
var parameter = header.Value.Parameter;
|
||||
var type = _typeFactory.CreateType(parameter.Type);
|
||||
using (type.IsNullable ? If($"{parameter.Name} != null") : null)
|
||||
{
|
||||
//TODO: Determine conditions in which to ToString() or not
|
||||
Line($"request.Headers.Add(\"{pair.Key}\", {parameter.Name}.ToString()!);");
|
||||
Append($"request.Headers.Add(\"{header.Name}\",");
|
||||
Append(parameter.Name);
|
||||
if (type.IsNullable && type.IsValueType)
|
||||
{
|
||||
Append(".Value");
|
||||
}
|
||||
|
||||
WriteHeaderFormat(header.Format);
|
||||
Line(");");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,6 +172,22 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
}
|
||||
}
|
||||
|
||||
private void WriteHeaderFormat(HeaderSerializationFormat format)
|
||||
{
|
||||
var formatSpecifier = format switch
|
||||
{
|
||||
HeaderSerializationFormat.DateTimeRFC1123 => "R",
|
||||
HeaderSerializationFormat.DateTimeISO8601 => "S",
|
||||
HeaderSerializationFormat.Date => "D",
|
||||
_ => null
|
||||
};
|
||||
|
||||
if (formatSpecifier != null)
|
||||
{
|
||||
Append($", \"{formatSpecifier}\"");
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Do multiple status codes
|
||||
private void WriteStatusCodeSwitch(ClientTypeReference schemaResponse, CSharpType responseType, ClientMethod operation)
|
||||
{
|
||||
|
|
|
@ -51,7 +51,8 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
return new CSharpType(
|
||||
new CSharpNamespace(_namespace.NullIfEmpty(), "Models", apiVersion != null ? $"V{apiVersion}" : schema.Language.Default.Namespace),
|
||||
type.Name,
|
||||
isNullable: schemaReference.IsNullable);
|
||||
isNullable: schemaReference.IsNullable,
|
||||
isValueType: type is ClientEnum);
|
||||
}
|
||||
|
||||
public CSharpType CreateType(ServiceClient clientTypeProvider) =>
|
||||
|
|
|
@ -24,11 +24,14 @@ namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
|
|||
{
|
||||
name = name.Substring(2);
|
||||
}
|
||||
_arguments[name] = parts[1];
|
||||
if (parts.Length == 1)
|
||||
{
|
||||
_arguments[name] = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
_arguments[name] = parts[1];
|
||||
}
|
||||
}
|
||||
|
||||
_basePath = _arguments["base-path"];
|
||||
|
|
|
@ -42,6 +42,9 @@ namespace AutoRest.CSharp.V3
|
|||
if (codeModelFileName.IsNullOrEmpty()) throw new Exception("Generator did not receive the code model file.");
|
||||
|
||||
var codeModelYaml = await autoRest.ReadFile(codeModelFileName);
|
||||
|
||||
await autoRest.WriteFile("CodeModel.yaml", codeModelYaml, "source-file-csharp");
|
||||
|
||||
codeModel = Serialization.DeserializeCodeModel(codeModelYaml);
|
||||
}
|
||||
var configuration = Configuration.Create(autoRest);
|
||||
|
|
|
@ -12,6 +12,7 @@ using AutoRest.CSharp.V3.JsonRpc.MessageModels;
|
|||
using AutoRest.CSharp.V3.Pipeline;
|
||||
using AutoRest.CSharp.V3.Pipeline.Generated;
|
||||
using Azure.Core;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
namespace AutoRest.CSharp.V3.Plugins
|
||||
{
|
||||
|
@ -57,7 +58,9 @@ namespace AutoRest.CSharp.V3.Plugins
|
|||
new ServiceClient(arg.CSharpName(), arg.Operations.Select(BuildMethod).Where(method => method != null).ToArray()!);
|
||||
|
||||
private static ClientConstant? CreateDefaultValueConstant(Parameter requestParameter) =>
|
||||
requestParameter.ClientDefaultValue != null ? new ClientConstant(requestParameter.ClientDefaultValue, new FrameworkTypeReference(typeof(object))) : (ClientConstant?)null;
|
||||
requestParameter.ClientDefaultValue != null ?
|
||||
new ClientConstant(requestParameter.ClientDefaultValue, (FrameworkTypeReference) CreateType(requestParameter.Schema, requestParameter.IsNullable())) :
|
||||
(ClientConstant?)null;
|
||||
|
||||
private static ClientMethod? BuildMethod(Operation operation)
|
||||
{
|
||||
|
@ -72,7 +75,7 @@ namespace AutoRest.CSharp.V3.Plugins
|
|||
|
||||
Dictionary<string, ConstantOrParameter> parameters = new Dictionary<string, ConstantOrParameter>();
|
||||
List<QueryParameter> query = new List<QueryParameter>();
|
||||
List<KeyValuePair<string, ConstantOrParameter>> headers = new List<KeyValuePair<string, ConstantOrParameter>>();
|
||||
List<RequestHeader> headers = new List<RequestHeader>();
|
||||
|
||||
ConstantOrParameter? body = null;
|
||||
foreach (Parameter requestParameter in operation.Request.Parameters ?? Array.Empty<Parameter>())
|
||||
|
@ -113,7 +116,7 @@ namespace AutoRest.CSharp.V3.Plugins
|
|||
switch (httpParameter.In)
|
||||
{
|
||||
case ParameterLocation.Header:
|
||||
headers.Add(KeyValuePair.Create(serializedName, constantOrParameter.Value));
|
||||
headers.Add(new RequestHeader(serializedName, constantOrParameter.Value, ToHeaderFormat(requestParameter.Schema)));
|
||||
break;
|
||||
case ParameterLocation.Query:
|
||||
query.Add(new QueryParameter(serializedName, constantOrParameter.Value, true));
|
||||
|
@ -130,7 +133,7 @@ namespace AutoRest.CSharp.V3.Plugins
|
|||
|
||||
if (httpRequest is HttpWithBodyRequest httpWithBodyRequest)
|
||||
{
|
||||
headers.AddRange(httpWithBodyRequest.MediaTypes.Select(mediaType => KeyValuePair.Create("Content-Type", new ConstantOrParameter(StringConstant(mediaType)))));
|
||||
headers.AddRange(httpWithBodyRequest.MediaTypes.Select(mediaType => new RequestHeader("Content-Type", new ConstantOrParameter(StringConstant(mediaType)))));
|
||||
}
|
||||
|
||||
var request = new ClientMethodRequest(
|
||||
|
@ -158,6 +161,17 @@ namespace AutoRest.CSharp.V3.Plugins
|
|||
);
|
||||
}
|
||||
|
||||
private static HeaderSerializationFormat ToHeaderFormat(Schema schema)
|
||||
{
|
||||
return schema switch
|
||||
{
|
||||
DateTimeSchema dateTimeSchema when dateTimeSchema.Format == DateTimeSchemaFormat.DateTime => HeaderSerializationFormat.DateTimeISO8601,
|
||||
DateSchema _ => HeaderSerializationFormat.Date,
|
||||
DateTimeSchema dateTimeSchema when dateTimeSchema.Format == DateTimeSchemaFormat.DateTimeRfc1123 => HeaderSerializationFormat.DateTimeRFC1123,
|
||||
_ => HeaderSerializationFormat.Default,
|
||||
};
|
||||
}
|
||||
|
||||
private static ConstantOrParameter[] ToParts(string httpRequestUri, Dictionary<string, ConstantOrParameter> parameters)
|
||||
{
|
||||
List<ConstantOrParameter> host = new List<ConstantOrParameter>();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
},
|
||||
"Standalone": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "--standalone --input-codemodel=d:\\github\\azure\\autorest.csharp\\test\\AutoRest.TestServer.Tests\\body-string\\CodeModel-body-string.yaml --plugin=cs-modeler --base-path=D:/github/azure/autorest.csharp/test/AutoRest.TestServer.Tests/body-string/ --namespace=body_string"
|
||||
"commandLineArgs": "--standalone --input-codemodel=d:\\github\\azure\\autorest.csharp\\test\\TestServerProjects\\url\\CodeModel.yaml --plugin=cs-modeler --base-path=D:/github/azure/autorest.csharp/test/TestServerProjects/url/ --namespace=url"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace Azure.Core
|
||||
{
|
||||
internal static class RequestHeaderExtensions
|
||||
{
|
||||
public static void Add(this RequestHeaders headers, string name, bool value)
|
||||
{
|
||||
headers.Add(name, value ? "true" : "false");
|
||||
}
|
||||
|
||||
public static void Add(this RequestHeaders headers, string name, float value)
|
||||
{
|
||||
headers.Add(name, value.ToString("G"));
|
||||
}
|
||||
|
||||
public static void Add(this RequestHeaders headers, string name, double value)
|
||||
{
|
||||
headers.Add(name, value.ToString("G"));
|
||||
}
|
||||
|
||||
public static void Add(this RequestHeaders headers, string name, int value)
|
||||
{
|
||||
headers.Add(name, value.ToString("G"));
|
||||
}
|
||||
|
||||
public static void Add(this RequestHeaders headers, string name, DateTime value, string format)
|
||||
{
|
||||
string formatted = format switch
|
||||
{
|
||||
"D" => value.ToString("yyyy-MM-dd"),
|
||||
"S" => value.ToString("yyyy-MM-ddTHH:mm:ssZ"),
|
||||
"R" => value.ToString("R"),
|
||||
_ => throw new ArgumentException("Format is not supported", nameof(format))
|
||||
};
|
||||
headers.Add(name, formatted);
|
||||
}
|
||||
|
||||
public static void Add(this RequestHeaders headers, string name, TimeSpan value)
|
||||
{
|
||||
headers.Add(name, XmlConvert.ToString(value));
|
||||
}
|
||||
|
||||
public static void Add(this RequestHeaders headers, string name, byte[] value)
|
||||
{
|
||||
headers.Add(name, Convert.ToBase64String(value));
|
||||
}
|
||||
|
||||
public static void Add<T>(this RequestHeaders headers, string name, T value) where T: struct
|
||||
{
|
||||
headers.Add(name, value.ToString()!);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,9 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using header;
|
||||
using header.Models.V100;
|
||||
|
@ -13,8 +15,13 @@ namespace AutoRest.TestServer.Tests
|
|||
[IgnoreOnTestServer(TestServerVersion.V2, "Too many missing or too strict recordings")]
|
||||
public class HeaderTests : TestServerTestBase
|
||||
{
|
||||
private static readonly DateTime MinDate = new DateTime(0001, 1, 1, 0, 0, 0);
|
||||
private static readonly DateTime ValidDate = new DateTime(2010, 1, 1, 12, 34, 56);
|
||||
public HeaderTests(TestServerVersion version) : base(version, "header") { }
|
||||
|
||||
public static byte[] ByteArray { get; } =
|
||||
Encoding.UTF8.GetBytes("啊齄丂狛狜隣郎隣兀﨩");
|
||||
|
||||
[Test]
|
||||
public Task HeaderParameterExistingKey() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamExistingKeyAsync(ClientDiagnostics, pipeline, "overwrite", host: host));
|
||||
|
||||
|
@ -77,11 +84,9 @@ namespace AutoRest.TestServer.Tests
|
|||
public Task HeaderResponseDoubleNegative() => TestStatus(async (host, pipeline) => await HeaderOperations.ResponseDoubleAsync(ClientDiagnostics, pipeline, scenario: "negative", host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("bool.ToString() has wrong casing")]
|
||||
public Task HeaderParameterBoolFalse() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamBoolAsync(ClientDiagnostics, pipeline, scenario: "false", false, host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("bool.ToString() has wrong casing")]
|
||||
public Task HeaderParameterBoolTrue() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamBoolAsync(ClientDiagnostics, pipeline, scenario: "true", true, host: host));
|
||||
|
||||
[Test]
|
||||
|
@ -109,11 +114,9 @@ namespace AutoRest.TestServer.Tests
|
|||
public Task HeaderResponseStringEmpty() => TestStatus(async (host, pipeline) => await HeaderOperations.ResponseStringAsync(ClientDiagnostics, pipeline, scenario: "empty", host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("wrong date format")]
|
||||
public Task HeaderParameterDateValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDateAsync(ClientDiagnostics, pipeline, scenario: "valid", new DateTime(2010, 1, 1), host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("wrong date format")]
|
||||
public Task HeaderParameterDateMin() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDateAsync(ClientDiagnostics, pipeline, scenario: "min", new DateTime(0001, 1, 1), host: host));
|
||||
|
||||
[Test]
|
||||
|
@ -123,12 +126,10 @@ namespace AutoRest.TestServer.Tests
|
|||
public Task HeaderResponseDateMin() => TestStatus(async (host, pipeline) => await HeaderOperations.ResponseDateAsync(ClientDiagnostics, pipeline, scenario: "min", host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("wrong date format")]
|
||||
public Task HeaderParameterDateTimeValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDatetimeAsync(ClientDiagnostics, pipeline, scenario: "valid", new DateTime(2010, 1, 1, 12, 34, 56), host: host));
|
||||
public Task HeaderParameterDateTimeValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDatetimeAsync(ClientDiagnostics, pipeline, scenario: "valid", ValidDate, host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("wrong date format")]
|
||||
public Task HeaderParameterDateTimeMin() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDatetimeAsync(ClientDiagnostics, pipeline, scenario: "valid", new DateTime(2010, 1, 1, 12, 34, 56), host: host));
|
||||
public Task HeaderParameterDateTimeMin() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDatetimeAsync(ClientDiagnostics, pipeline, scenario: "min", MinDate, host: host));
|
||||
|
||||
[Test]
|
||||
public Task HeaderResponseDateTimeValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ResponseDatetimeAsync(ClientDiagnostics, pipeline, scenario: "valid", host: host));
|
||||
|
@ -137,12 +138,10 @@ namespace AutoRest.TestServer.Tests
|
|||
public Task HeaderResponseDateTimeMin() => TestStatus(async (host, pipeline) => await HeaderOperations.ResponseDatetimeAsync(ClientDiagnostics, pipeline, scenario: "min", host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("wrong date format")]
|
||||
public Task HeaderParameterDateTimeRfc1123Valid() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDatetimeRfc1123Async(ClientDiagnostics, pipeline, scenario: "valid", new DateTime(2010, 1, 1, 12, 34, 56), host: host));
|
||||
public Task HeaderParameterDateTimeRfc1123Valid() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDatetimeRfc1123Async(ClientDiagnostics, pipeline, scenario: "valid", ValidDate, host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("wrong date format")]
|
||||
public Task HeaderParameterDateTimeRfc1123Min() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDatetimeRfc1123Async(ClientDiagnostics, pipeline, scenario: "min", new DateTime(2010, 1, 1, 12, 34, 56), host: host));
|
||||
public Task HeaderParameterDateTimeRfc1123Min() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDatetimeRfc1123Async(ClientDiagnostics, pipeline, scenario: "min", MinDate, host: host));
|
||||
|
||||
[Test]
|
||||
public Task HeaderResponseDateTimeRfc1123Valid() => TestStatus(async (host, pipeline) => await HeaderOperations.ResponseDatetimeRfc1123Async(ClientDiagnostics, pipeline, scenario: "valid", host: host));
|
||||
|
@ -151,15 +150,13 @@ namespace AutoRest.TestServer.Tests
|
|||
public Task HeaderResponseDateTimeRfc1123Min() => TestStatus(async (host, pipeline) => await HeaderOperations.ResponseDatetimeRfc1123Async(ClientDiagnostics, pipeline, scenario: "min", host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("wrong duration format")]
|
||||
public Task HeaderParameterDurationValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDurationAsync(ClientDiagnostics, pipeline, scenario: "valid", TimeSpan.FromSeconds(1), host: host));
|
||||
public Task HeaderParameterDurationValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamDurationAsync(ClientDiagnostics, pipeline, scenario: "valid", XmlConvert.ToTimeSpan("P123DT22H14M12.011S"), host: host));
|
||||
|
||||
[Test]
|
||||
public Task HeaderResponseDurationValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ResponseDurationAsync(ClientDiagnostics, pipeline, scenario: "valid", host: host));
|
||||
|
||||
[Test]
|
||||
[Ignore("Byte[] not supported")]
|
||||
public Task HeaderParameterBytesValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamByteAsync(ClientDiagnostics, pipeline, scenario: "valid", new byte[1], host: host));
|
||||
public Task HeaderParameterBytesValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ParamByteAsync(ClientDiagnostics, pipeline, scenario: "valid", ByteArray, host: host));
|
||||
|
||||
[Test]
|
||||
public Task HeaderResponseBytesValid() => TestStatus(async (host, pipeline) => await HeaderOperations.ResponseByteAsync(ClientDiagnostics, pipeline, scenario: "valid", host: host));
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/existingkey", false);
|
||||
request.Headers.Add("User-Agent", userAgent.ToString()!);
|
||||
request.Headers.Add("User-Agent", userAgent);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -64,7 +64,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/protectedkey", false);
|
||||
request.Headers.Add("Content-Type", contentType.ToString()!);
|
||||
request.Headers.Add("Content-Type", contentType);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -105,8 +105,8 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/integer", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
request.Headers.Add("value", value);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -127,7 +127,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/integer", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -148,8 +148,8 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/long", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
request.Headers.Add("value", value);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -170,7 +170,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/long", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -191,8 +191,8 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/float", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
request.Headers.Add("value", value);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -213,7 +213,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/float", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -234,8 +234,8 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/double", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
request.Headers.Add("value", value);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -256,7 +256,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/double", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -277,8 +277,8 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/bool", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
request.Headers.Add("value", value);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -299,7 +299,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/bool", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -320,10 +320,10 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/string", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
if (value != null)
|
||||
{
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("value", value);
|
||||
}
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
@ -345,7 +345,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/string", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -366,8 +366,8 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/date", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
request.Headers.Add("value", value, "D");
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -388,7 +388,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/date", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -409,8 +409,8 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/datetime", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
request.Headers.Add("value", value, "S");
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -431,7 +431,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/datetime", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -452,10 +452,10 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/datetimerfc1123", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
if (value != null)
|
||||
{
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("value", value.Value, "R");
|
||||
}
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
@ -477,7 +477,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/datetimerfc1123", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -498,8 +498,8 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/duration", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
request.Headers.Add("value", value);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -520,7 +520,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/duration", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -541,8 +541,8 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/byte", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
request.Headers.Add("value", value);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -563,7 +563,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/byte", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
@ -584,10 +584,10 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/param/prim/enum", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
if (value != null)
|
||||
{
|
||||
request.Headers.Add("value", value.ToString()!);
|
||||
request.Headers.Add("value", value.Value);
|
||||
}
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
@ -609,7 +609,7 @@ namespace header
|
|||
request.Method = RequestMethod.Post;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/header/response/prim/enum", false);
|
||||
request.Headers.Add("scenario", scenario.ToString()!);
|
||||
request.Headers.Add("scenario", scenario);
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
|
|
Загрузка…
Ссылка в новой задаче