Если вы хотите установить пользовательский заголовок, вы можете обратиться к следующему коду:
public static class Function1
{
[FunctionName("Function1")]
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string testheader = req.Headers.GetValues("testheader").FirstOrDefault();
string executionTime = DateTime.UtcNow.ToString();
var httpresponse = req.CreateResponse(HttpStatusCode.OK, new
{
Testheader = testheader,
ExecutionTime = executionTime
}, "application/json");
httpresponse.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
httpresponse.Headers.Add("Warning", "custom header");
return httpresponse;
}
}
Этот код добавляет пользовательский заголовок warning
со значением 299 - "Deprecated API"
и изменяет заголовок content-type
.
Надеюсь, это поможет вам, если у вас все еще есть другие проблемы, пожалуйста, дайте мне знать.