Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using the current approach, and in the proposed changes in #248, we have of storing fields in a structured format is challenging to achieve compatibility with unusual behavior of Fastly's RFC-8941 header dictionary implementation.
This PRs implementation takes the approach of extracting the field being operated on at the time of access using the observed behavior of Fastly's implementation.
With this approach edge cases in how fastly handles things can be correctly supported for example dealing with fields that contain the field separator.
The regular expression used in this is admittedly quite opaque and was derived through trial and error based on observing Fastly behavior in as many cases as I could come up with. This same general approach could be achieved with an iterative parser which would be easier to follow what is happening but would be considerably more code. If there is maintainability concern with the regex approach I'm happy to rework this.
Additionally the
subfield
built-in function shares the field access behavior of the:
operator. Updated that function to share the same implementation.This implementation was validated against Fastly's behavior using this suite of tests:
https://github.com/richardmarshall/falco-validation-tests/blob/main/header_fields/main.test.vcl