Disable Connection:keep alive in Jetty 9

Solution 1:

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">
      <Arg>
        <New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
          <Set name="name">Connection</Set>
          <Set name="value">close</Set>
        </New>
      </Arg>
    </Call>

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