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

Jetty 12: X-Powered-By header is added 2 times (if enabled) #10309

Closed
uschindler opened this issue Aug 14, 2023 · 3 comments · Fixed by #10310
Closed

Jetty 12: X-Powered-By header is added 2 times (if enabled) #10309

uschindler opened this issue Aug 14, 2023 · 3 comments · Fixed by #10310
Assignees
Labels
Bug For general bugs on Jetty side
Milestone

Comments

@uschindler
Copy link

Jetty version(s)
Jetty 12

Jetty Environment
core

Description
If you enable HttpConfiguration#setSendXPoweredBy(true), then Jetty returns the header 2 times (at least with HTTP/1.1):

> curl -I http://localhost:8081/
HTTP/1.1 200 OK
X-Powered-By: Jetty(12.0.0)
Date: Mon, 14 Aug 2023 18:38:26 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 46
X-Powered-By: Jetty(12.0.0)
@uschindler uschindler added the Bug For general bugs on Jetty side label Aug 14, 2023
@uschindler uschindler changed the title X-Powered-By header is added 2 times (if enabled) Jetty 12: X-Powered-By header is added 2 times (if enabled) Aug 14, 2023
@uschindler
Copy link
Author

Simple reproducer:

public class JettyTest {

  public static void main(String[] args) throws Exception {
    final var server=new Server();
    
    // setup connector
    final var http_config = new HttpConfiguration();
    final var cust = new ForwardedRequestCustomizer();
    http_config.addCustomizer(cust);
    http_config.setSendServerVersion(false);
    http_config.setSendXPoweredBy(true);
    final var connector = new ServerConnector(server, new HttpConnectionFactory(http_config));
    connector.setHost(System.getProperty("server.host", "127.0.0.1"));
    connector.setPort(Integer.getInteger("server.port", 8081));
    server.addConnector(connector);

    // startup:
    server.start();
    server.join();
  }
}

@joakime joakime linked a pull request Aug 14, 2023 that will close this issue
@joakime
Copy link
Contributor

joakime commented Aug 14, 2023

Opened PR #10310 to address this

@joakime joakime moved this to 🏗 In progress in Jetty 12.0.1 - FROZEN Aug 14, 2023
@joakime joakime self-assigned this Aug 14, 2023
@joakime joakime added this to the 12.0.x milestone Aug 14, 2023
joakime added a commit that referenced this issue Aug 21, 2023
* Make HttpChannelState responsible for X-Powered-By / Server headers
* Remove X-Powered-By handling in HttpGenerator
@joakime
Copy link
Contributor

joakime commented Aug 23, 2023

Basic fix merged in PR #10310

@joakime joakime closed this as completed Aug 23, 2023
@joakime joakime moved this from 🏗 In progress to ✅ Done in Jetty 12.0.1 - FROZEN Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants