Skip to content

Allow setting parts for http trigger response when function returns a json #5563

@pragnagopa

Description

@pragnagopa

cc @mhoeger

Following code allows setting StatusCode, Headers, Query etc on http response only if body is set.

if (responseObject.TryGetValue(RpcWorkerConstants.RpcHttpBody, out bodyValue, ignoreCase: true))
{
// the response content becomes the specified body value
content = bodyValue;
if (responseObject.TryGetValue(RpcWorkerConstants.RpcHttpHeaders, out IDictionary<string, object> headersValue, ignoreCase: true))
{
headers = headersValue;
}
if (TryParseStatusCode(responseObject, out int? responseStatusCode))
{
statusCode = responseStatusCode.Value;
}
if (responseObject.TryGetValue<bool>(RpcWorkerConstants.RpcHttpEnableContentNegotiation, out bool enableContentNegotiationValue, ignoreCase: true))
{
enableContentNegotiation = enableContentNegotiationValue;
}
if (responseObject.TryGetValue(RpcWorkerConstants.RpcHttpCookies, out List<Tuple<string, string, CookieOptions>> cookiesValue, ignoreCase: true))
{
cookies = cookiesValue;
}
}

This code effects out-of-proc and .csx functions. Fixing it would be breaking change. Have to fix this as part of next major release.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions