Skip to content

Cache-Control parsing differs from other headers #68901

@MihaZupan

Description

@MihaZupan

Normally when headers are parsed, each value from the input string is turned into one parsed value entry.
After changes like #65249 and #67227, the insertion order of values is now preserved when enumerating.

The only exception here is Cache-Control. It uses a single CacheControlHeaderValue object to store all values.
This has a few downsides:

  • The order of values is not preserved
  • Parsing logic for this header has to be aware of implementation details of how headers are stored
    • It needs this logic to find the CacheControlHeaderValue.
    • Since it's the only header reusing a storage object like this, it adds an extra storeValue parameter to the method that all other parsers ignore.
  • Parsing logic has to account for this edge-case, as the out parsedValue parameter may not be set even if the value is valid and was successfully parsed and saved.
    • I am referring to complications in TryParseAndAddRawHeaderValue. As a result, we can't support some edge-cases like storing multiple whitespace-only values for a single header.

We should try to see if it's possible to make Cache-Control parsing work more like the other headers, without introducing breaking changes for existing users of the strongly-typed CacheControlHeaderValue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions