Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,51 @@ internal static async Task<TypedData> ToRpcHttp(this HttpRequest request, ILogge
foreach (var pair in request.Query)
{
var value = pair.Value.ToString();
if (!string.IsNullOrEmpty(value))
if (ShouldUseNullableValueDictionary(capabilities))
{
http.Query.Add(pair.Key, value);
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 (ShouldIgnoreEmptyHeaderValues(capabilities) && string.IsNullOrEmpty(pair.Value.ToString()))
if (ShouldUseNullableValueDictionary(capabilities))
{
continue;
http.NullableHeaders.Add(pair.Key.ToLowerInvariant(), new NullableString { Value = pair.Value.ToString() });
}
else
{
if (ShouldIgnoreEmptyHeaderValues(capabilities) && string.IsNullOrEmpty(pair.Value.ToString()))
{
continue;
}

http.Headers.Add(pair.Key.ToLowerInvariant(), pair.Value.ToString());
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 (pair.Value != null)
if (ShouldUseNullableValueDictionary(capabilities))
{
http.NullableParams.Add(pair.Key, new NullableString { Value = pair.Value.ToString() });
}
else
{
http.Params.Add(pair.Key, pair.Value.ToString());
if (pair.Value != null)
{
http.Params.Add(pair.Key, pair.Value.ToString());
}
}
}
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/WebJobs.Script/Workers/Rpc/RpcWorkerConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down