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

[Question] How can I insert a HTTP header only when that header does not exist? #22713

Closed
SpecialYang opened this issue Aug 16, 2022 · 5 comments · Fixed by #22723
Closed

[Question] How can I insert a HTTP header only when that header does not exist? #22713

SpecialYang opened this issue Aug 16, 2022 · 5 comments · Fixed by #22723
Labels
enhancement Feature requests. Not bugs or questions. help wanted Needs help!

Comments

@SpecialYang
Copy link
Contributor

SpecialYang commented Aug 16, 2022

For example, I want to add a HTTP header foo: bar into request when the original request does not have the HTTP header foo. But, if the original request have the HTTP header foo, envoy should do nothing header manipulation for this request.

The existing setting HeaderValueOption can't resolve this issue. Please correct me if i am wrong.

CC @wbpcode

@SpecialYang SpecialYang added the triage Issue requires triage label Aug 16, 2022
@wbpcode wbpcode added question Questions that are neither investigations, bugs, nor enhancements enhancement Feature requests. Not bugs or questions. help wanted Needs help! and removed triage Issue requires triage question Questions that are neither investigations, bugs, nor enhancements labels Aug 16, 2022
@wbpcode
Copy link
Member

wbpcode commented Aug 16, 2022

Hmm, yeah, although the new option was added in the #18246, the implementation is still absent.

@wbpcode
Copy link
Member

wbpcode commented Aug 16, 2022

I will try to land it.

@soulxu
Copy link
Member

soulxu commented Aug 16, 2022

A workaround should be able to do that for now before @wbpcode land it

              routes:
              - match:
                  prefix: "/"
                  headers:
                  - name: "foo"
                    present_match: false
                route:
                  cluster: my_cluster
                request_headers_to_add:
                - header:
                    key: foo
                    value: bar
              - match:
                  prefix: "/"
                  headers:
                  - name: "foo"
                    present_match: true
                route:
                  cluster: my_cluster

@SpecialYang
Copy link
Contributor Author

A workaround should be able to do that for now before @wbpcode land it

              routes:
              - match:
                  prefix: "/"
                  headers:
                  - name: "foo"
                    present_match: false
                route:
                  cluster: my_cluster
                request_headers_to_add:
                - header:
                    key: foo
                    value: bar
              - match:
                  prefix: "/"
                  headers:
                  - name: "foo"
                    present_match: true
                route:
                  cluster: my_cluster

Thank you. But it is difficult for the scale deployment.

@soulxu
Copy link
Member

soulxu commented Aug 16, 2022

A workaround should be able to do that for now before @wbpcode land it

              routes:
              - match:
                  prefix: "/"
                  headers:
                  - name: "foo"
                    present_match: false
                route:
                  cluster: my_cluster
                request_headers_to_add:
                - header:
                    key: foo
                    value: bar
              - match:
                  prefix: "/"
                  headers:
                  - name: "foo"
                    present_match: true
                route:
                  cluster: my_cluster

Thank you. But it is difficult for the scale deployment.

np! yea, that could be a combination explosion.

htuch pushed a commit that referenced this issue Aug 26, 2022
The HeaderAppendAction was added in the #18246. But the implementation never done. This PR try to complete this feature.

Further work of #18246. To close #22713.

Risk Level: Low.
Testing: Unit Test.

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests. Not bugs or questions. help wanted Needs help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants