Disable Connection:keep alive in Jetty 9

flavian asked:

How do you disable keep-alive in Jetty 9?

Running under 64 bit CentOS if it makes a difference.

An XML config solution is preferred.

My answer:

You really don’t want to disable keep-alive. Your server performance will suffer, for starters. Your clients will experience slower loading times. In rare cases, you may even get fired.

Don’t even THINK about doing this on a production web site.

If you’re just testing, you can set the HTTP header Connection: Close.

<Configure id="Server" class="org.eclipse.jetty.server.Server">
  <New id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">

    <Call name="addRule">
        <New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
          <Set name="name">Connection</Set>
          <Set name="value">close</Set>

  <Set name="handler"><Ref id="Rewrite" /></Set>

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.