Azure / Azure/azure-functions-host

Parsing Inconsistency with Multiple Values for an HTTP Header

Open
#5,294 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

For an `HttpTrigger` function, the provided `HttpRequestMessage` and its `HttpHeaders` collection has different behavior with respect to duplicate headers when executing locally and when executing in Azure. The behavior when executing in Azure appears to be incorrect.

#### Investigative information

Azure Functions Core Tools (2.7.1846 Commit hash: 58c671341fda1c52bd46e1aa8943cb26e467830)
Function Runtime Version: 2.0.12858.0
.NET Core SDK: 3.0.101

#### Repro steps

Suppose the request sent to a function has additional HTTP headers specified such as:

```
X-Some-Header: ValueA
X-Some-Header: ValueB
```

#### Expected behavior

I expect the `HttpHeaders` collection to have an entry with a key of `"X-Some-Header"` and an enumerable value consisting of two separate strings such as: `["ValueA", "ValueB"]`. This is the behavior observed when running the function locally.

#### Actual behavior

When running the function in Azure, the `HttpHeaders` collection has an entry with a key of `"X-Some-Header"` and an enumerable value consisting of a single concatenated string like: `["ValueA, ValueB"]`.

#### Known workarounds

Obviously one could split the header values, but this may be unreliable if the header values can contain a comma.

This subtle difference in behavior between environments was not expected and could be difficult to identify and troubleshoot.

Contributor guide

Open the contributing guide

Research direction

Start with the HttpTrigger handling of HttpRequestMessage and its HttpHeaders collection, reproducing the duplicate X-Some-Header request locally and in Azure using the versions listed. Trace where duplicate values are converted between the two environments; done means Azure exposes ["ValueA", "ValueB"] rather than ["ValueA, ValueB"] without breaking comma-containing values.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
api, backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.