Skip to content

Question: AbstractProxyServlet onServerResponseHeaders addHeader rather than setHeaderΒ #577

Closed

Description

@tongc

We have a listener implmenets org.eclipse.jetty.client.api.Response.Listener class
and for onHeaders method we have the following implementation

    @Override
    public void onHeaders(Response response) {
        wrappedVersion.onHeaders(response);
    }

this wrappedVersion.onHeaders calls ProxyResponseListener then calls AbstractProxyServlet's onServerResponseHeaders method which calls addHeader.

This is a problem for us because we have configured org.eclipse.jetty.servlets.CrossOriginFilter which has handleSimpleResponse which calls response.setHeader(ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, origin);

And this CORS filter is called before our filter. Which means for our filter onHeaders, rather than replacing the headers, it actually added more headers.

I wonder why Jetty doesn't do setHeader in onServerResponseHeaders? I am guessing this is because we do not want to lose any set cookie headers?
And what would be a better design if its something we can improve on our side?

thanks

Activity

  1. changed the title [-]AbstractProxyServlet onServerResponseHeaders addHeader rather than setHeader[/-] [+]Question: AbstractProxyServlet onServerResponseHeaders addHeader rather than setHeader[/+] on May 18, 2016
  2. joakime commented on Mar 22, 2019

    @joakime
    Contributor

    @sbordet old jetty-client API question.

  3. stale commented on Mar 21, 2020

    @stale

    This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

  4. added
    StaleFor auto-closed stale issues and pull requests
    on Mar 21, 2020
  5. removed
    StaleFor auto-closed stale issues and pull requests
    on Mar 24, 2020
  6. stale commented on Apr 23, 2020

    @stale

    This issue has been closed due to it having no activity.

  7. stale commented on Jun 2, 2021

    @stale

    This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

  8. added
    StaleFor auto-closed stale issues and pull requests
    on Jun 2, 2021
  9. removed
    StaleFor auto-closed stale issues and pull requests
    on Jun 4, 2021
  10. github-actions commented on Jun 6, 2022

    @github-actions

    This issue has been automatically marked as stale because it has been a
    full year without activity. It will be closed if no further activity occurs.
    Thank you for your contributions.

  11. added
    StaleFor auto-closed stale issues and pull requests
    on Jun 6, 2022
  12. removed
    StaleFor auto-closed stale issues and pull requests
    on Jun 13, 2022
  13. 22 remaining items

  14. linked a pull request that will close this issueFixes proxy duplicate headers #15393on Jul 9, 2026
  15. moved this to πŸ— In progress in Jetty 12.1.12 FROZENon Jul 9, 2026
  16. added a commit that references this issue on Jul 13, 2026
    55886a8
  17. moved this from πŸ— In progress to βœ… Done in Jetty 12.1.12 FROZENon Jul 13, 2026
  18. added a commit that references this issue on Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions