Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] (simulator) Behavior when multiple lines have the same header. #237

Open
bungoume opened this issue Dec 26, 2023 · 0 comments
Open
Assignees

Comments

@bungoume
Copy link
Contributor

Describe the problem
Fastly seems to exhibit a special behavior when there are multiple lines with the same header.
https://fiddle.fastly.dev/fiddle/6221d4db

While the specific behavior needs to be verified accurately, I'll write test cases based on the current understanding.

  • Only the Header listed at the beginning is utilized:
    • When assigned, the value from the first instance is used.
    • Conditions such as 'if' statements use the value from the initial entry.
    • Writing using : such as set req.http.HEADER:V = ""; overwrites the first header entry, erasing subsequent entries from the second onwards.
  • Header sequence reverses during the fetch process.
  • Regardless of the presence of multiple lines, using unset removes all lines.
  • Even with multiple lines, using set retains only that single line.
  • At the stage of the Response from Fastly, multiple lines consolidate into a single header separated by commas.

VCL code that cause the problem / reproduceable
https://fiddle.fastly.dev/fiddle/aa00bc57

// @scope: recv
// @suite: ADD header(add-add-add) BUGGY
sub test_recv {
    add req.http.VALUE = "V1";
    add req.http.VALUE = "V2";
    add req.http.VALUE = "V3";
    # assert.equal(req.http.VALUE, "V1, V2, V3");  # request upstream with 3 line headers
    # assert.equal(resp.http.VALUE, "V1, V2, V3");  # response contains single line header with three values.

    set req.http.MESSAGE = req.http.VALUE;  # set first header value
    assert.equal(req.http.MESSAGE, "V1");
}

// @scope: recv
// @suite: ADD header(set-add-add) BUGGY
sub test_recv {
    set req.http.VALUE = "V1";
    add req.http.VALUE = "V2";
    add req.http.VALUE = "V3";
    # assert.equal(req.http.VALUE, "V1, V2, V3");  # request upstream with 3 headers

    set req.http.MESSAGE = req.http.VALUE;  # set first header value
    assert.equal(req.http.MESSAGE, "V1");
}

// @scope: recv
// @suite: ADD header(add-add-set)
sub test_recv {
    add req.http.VALUE = "V1";
    add req.http.VALUE = "V2";
    set req.http.VALUE = "V3";
    assert.equal(req.http.VALUE, "V3");  # 1 header

    set req.http.MESSAGE = req.http.VALUE;
    assert.equal(req.http.MESSAGE, "V3");
}

// @scope: recv
// @suite: UNSET header(add-add-unset)
sub test_recv {
    add req.http.VALUE = "V1";
    add req.http.VALUE = "V2";
    unset req.http.VALUE;
    assert.is_notset(req.http.VALUE);  # 0 header

    set req.http.MESSAGE = req.http.VALUE;
    assert.equal(req.http.MESSAGE, "(null)");
}

Additional context
https://github.com/bungoume/falco-vcl-empty-test/blob/main/tests/header_multiline.test.vcl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants