Azure / Azure/azure-functions-powershell-worker

Adding header transfer-encoding= "chunked" to httptrigger causes body to be null

Open
#476 2 comments 0 reactions 2 assignees Claimed by @AnatoliB View on GitHub
investigation
Dominant language
C#
Stars
215
Forks
61
Avg merge
21h 4m
Merged PRs (30d)
6

Description

When adding the header: transfer-encoding = chunked to the request, the body comes into the function as null. Ran into this issue as our API gateway adds this header by default.
Reproduce:
Create simple function which returns the body back to the user:
``` pwsh
using namespace System.Net
param($Request, $TriggerMetadata)
$Request | ConvertTo-Json
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $($request.body|ConvertTo-Json)
})
```
Invoke the function to see that it works:
``` pwsh
invoke-webrequest -uri https://pwshfunction.azurewebsites.net/api/httptrigger1 -method post -SkipHttpErrorCheck -body $(@{test="value"}|ConvertTo-Json) -contenttype application/json
```
Now add the header:
``` pwsh
invoke-webrequest -uri https://pwshfunction.azurewebsites.net/api/httptrigger1 -method post -SkipHttpErrorCheck -body $(@{test="value"}|ConvertTo-Json) -contenttype application/json -headers @{ "transfer-encoding"= "chunked"}
```
You can monitor the logstream, and see the body is null:
2020-06-12T08:22:24Z [Information] OUTPUT: {
"Body": null,
"Headers": {
"connection": "Keep-Alive",
"content-type": "application/json",
"host": "pwshfunction.azurewebsites.net",
"max-forwards": "9",
"transfer-encoding": "chunked",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Microsoft Windows 10.0.18363; en-US) PowerShell/7.0.1",
"x-waws-unencoded-url": "/api/httptrigger1",
"client-ip": "10.0.128.33:48027",
"x-site-deployment-id": "pwshfunction",
"was-default-hostname": "pwshfunction.azurewebsites.net",
"x-original-url": "/api/httptrigger1",
"x-arr-ssl": "2048|256|C=US, S=Washington, L=Redmond, O=Microsoft Corporation, OU=Microsoft IT, CN=Microsoft IT TLS CA 5|CN=*.azurewebsites.net",
"x-forwarded-proto": "https",
"x-appservice-proto": "https",
"disguised-host": "pwshfunction.azurewebsites.net"
},
"Method": "POST",
"Url": "https://pwshfunction.azurewebsites.net/api/httptrigger1",
"Params": {},
"Query": {},
"RawBody": null
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.