Add nullable http proto
MODIFY
src/WebJobs.Script.Grpc/azure-functions-language-worker-protobuf/src/proto/FunctionRpc.proto
src/WebJobs.Script.Grpc/azure-functions-language-worker-protobuf/src/proto/FunctionRpc.proto
@@ -484,4 +484,7 @@ message RpcHttp {
TypedData rawBody = 17;
repeated RpcClaimsIdentity identities = 18;
repeated RpcHttpCookie cookies = 19;
+ map<string,NullableString> nullable_headers = 20;
+ map<string,NullableString> nullable_params = 21;
+ map<string,NullableString> nullable_query = 22;
}

MODIFY
src/WebJobs.Script/Workers/Rpc/MessageExtensions/RpcMessageConversionExtensions.cs
src/WebJobs.Script/Workers/Rpc/MessageExtensions/RpcMessageConversionExtensions.cs
@@ -128,13 +128,26 @@ internal static async Task<TypedData> ToRpcHttp(this HttpRequest request, ILogge
foreach (var pair in request.Query)
{
var value = pair.Value.ToString();
+ if (ShouldUseNullableValueDictionary(capabilities))
+ {
+ http.NullableQuery.Add(pair.Key, new NullableString { Value = value });
+ }
+ else
+ {
if (!string.IsNullOrEmpty(value))
{
http.Query.Add(pair.Key, value);
}
}
+ }
foreach (var pair in request.Headers)
+ {
+ if (ShouldUseNullableValueDictionary(capabilities))
+ {
+ http.NullableHeaders.Add(pair.Key.ToLowerInvariant(), new NullableString { Value = pair.Value.ToString() });
+ }
+ else
{
if (ShouldIgnoreEmptyHeaderValues(capabilities) && string.IsNullOrEmpty(pair.Value.ToString()))
{
@@ -143,11 +156,18 @@ internal static async Task<TypedData> ToRpcHttp(this HttpRequest request, ILogge
http.Headers.Add(pair.Key.ToLowerInvariant(), pair.Value.ToString());
}
+ }
if (request.HttpContext.Items.TryGetValue(HttpExtensionConstants.AzureWebJobsHttpRouteDataKey, out object routeData))
{
Dictionary<string, object> parameters = (Dictionary<string, object>)routeData;
foreach (var pair in parameters)
+ {
+ if (ShouldUseNullableValueDictionary(capabilities))
+ {
+ http.NullableParams.Add(pair.Key, new NullableString { Value = pair.Value.ToString() });
+ }
+ else
{
if (pair.Value != null)
{
@@ -155,6 +175,7 @@ internal static async Task<TypedData> ToRpcHttp(this HttpRequest request, ILogge
}
}
}
+ }
// parse ClaimsPrincipal if exists
if (request.HttpContext?.User?.Identities != null)
@@ -364,6 +385,11 @@ private static bool ShouldIgnoreEmptyHeaderValues(Capabilities capabilities)
return !string.IsNullOrEmpty(capabilities.GetCapabilityState(RpcWorkerConstants.IgnoreEmptyValuedRpcHttpHeaders));
}
+ private static bool ShouldUseNullableValueDictionary(Capabilities capabilities)
+ {
+ return !string.IsNullOrEmpty(capabilities.GetCapabilityState(RpcWorkerConstants.UseNullableValueDictionaryForHttp));
+ }
+
public static BindingInfo ToBindingInfo(this BindingMetadata bindingMetadata)
{
BindingInfo bindingInfo = new BindingInfo

MODIFY
src/WebJobs.Script/Workers/Rpc/RpcWorkerConstants.cs
src/WebJobs.Script/Workers/Rpc/RpcWorkerConstants.cs
@@ -37,6 +37,7 @@ public static class RpcWorkerConstants
public const string RpcHttpTriggerMetadataRemoved = "RpcHttpTriggerMetadataRemoved";
public const string IgnoreEmptyValuedRpcHttpHeaders = "IgnoreEmptyValuedRpcHttpHeaders";
public const string WorkerStatus = "WorkerStatus";
+ public const string UseNullableValueDictionaryForHttp = "UseNullableValueDictionaryForHttp";
// Host Capabilites
public const string V2Compatable = "V2Compatable";

Add nullable http proto (#6585)