Azure / Azure/azure-functions-host
Microsoft.AspNetCore.Server.Kestrel.Core throw when using Set-Cookie workaround
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 36
Description
This comment https://github.com/Azure/azure-functions-host/issues/2737#issuecomment-435149672 describes a workaround for setting multiple cookies in a HTTP triggered function. Unfortunatly it doesn't seem to work in azure-functions-core-tools
#Repro
```javascript
module.exports = async function (context, req) {
context.res = {
body: "Hello",
headers: {
"Set-Cookie": "cookie1=value",
"Set-Cookie ": "cookie2=value", // added extra space as a workaround from #2737 for setting multiple cookies
}
};
};
```
Calling this function yields `Microsoft.AspNetCore.Server.Kestrel.Core: Invalid non-ASCII or control character in header: 0x0020`. The `0x0020` bit probalby refers to the extra space character in the `Set-Cookie ` header. Here's an execution log from my local azure-functions-core-tools:
```powershell
Http Functions:
hello: [GET,POST] http://localhost:7071/api/hello
httpy: [GET,POST] http://localhost:7071/api/httpy
[18.02.2020 15:31:33] Executing HTTP request: {
[18.02.2020 15:31:33] "requestId": "a53111a4-2ce3-47d0-bfbc-0c71c8ba52b3",
[18.02.2020 15:31:33] "method": "GET",
[18.02.2020 15:31:33] "uri": "/api/httpy"
[18.02.2020 15:31:33] }
[18.02.2020 15:31:33] Executing 'Functions.httpy' (Reason='This function was programmatically called via the host APIs.', Id=9f86f521-8d48-4ac9-9e3b-91d80fe0f901)
[18.02.2020 15:31:33] Executed 'Functions.httpy' (Succeeded, Id=9f86f521-8d48-4ac9-9e3b-91d80fe0f901)
[18.02.2020 15:31:33] An unhandled host error has occurred.
[18.02.2020 15:31:33] Microsoft.AspNetCore.Server.Kestrel.Core: Invalid non-ASCII or control character in header: 0x0020.
[18.02.2020 15:31:33] Executed HTTP request: {
[18.02.2020 15:31:33] "requestId": "a53111a4-2ce3-47d0-bfbc-0c71c8ba52b3",
[18.02.2020 15:31:33] "method": "GET",
[18.02.2020 15:31:33] "uri": "/api/httpy",
[18.02.2020 15:31:33] "identities": [
[18.02.2020 15:31:33] {
[18.02.2020 15:31:33] "type": "WebJobsAuthLevel",
[18.02.2020 15:31:33] "level": "Admin"
[18.02.2020 15:31:33] }
[18.02.2020 15:31:33] ],
[18.02.2020 15:31:33] "status": 500,
[18.02.2020 15:31:33] "duration": 455
[18.02.2020 15:31:33] }
[18.02.2020 15:31:38] Host lock lease acquired by instance ID '00000000000000000000000064B2E1FD'.
```
# Environment:
```
PS C:\> node -v
v12.14.1
PS C:\> npm -v
6.13.4
PS C:\> func -v
2.7.2184
PS C:\> [System.Environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 18362 0
```
Contributor guide
Assessment
This issue has not been assessed yet.