<commit_before>package xitrum.handler.up

import io.netty.channel.{ChannelHandlerContext, ExceptionEvent, SimpleChannelUpstreamHandler}

import xitrum.Logger

/** Bad client = closed connection, malformed request etc. */
trait BadClientSilencer extends Logger {
  this: SimpleChannelUpstreamHandler =>

  override def exceptionCaught(ctx: ChannelHandlerContext, e: ExceptionEvent) {
    e.getChannel.close

    // Do nothing if the exception is one of the following:
    // java.io.IOException: Connection reset by peer
    // java.io.IOException: Broken pipe
    // java.nio.channels.ClosedChannelException: null
    // javax.net.ssl.SSLException: not an SSL/TLS record
    // java.lang.IllegalArgumentException: empty text (Use https://... to connect to HTTP server)
    val cause = e.getCause
    val s     = cause.toString
    if (s.startsWith("java.nio.channels.ClosedChannelException") ||<commit_msg>More info about javax.net.ssl.SSLException<commit_after>package xitrum.handler.up

import io.netty.channel.{ChannelHandlerContext, ExceptionEvent, SimpleChannelUpstreamHandler}
import xitrum.Logger

/** Bad client = closed connection, malformed request etc. */
trait BadClientSilencer extends Logger {
  this: SimpleChannelUpstreamHandler =>

  override def exceptionCaught(ctx: ChannelHandlerContext, e: ExceptionEvent) {
    e.getChannel.close

    // Do nothing if the exception is one of the following:
    // java.io.IOException: Connection reset by peer
    // java.io.IOException: Broken pipe
    // java.nio.channels.ClosedChannelException: null
    // javax.net.ssl.SSLException: not an SSL/TLS record (Use http://... URL to connect to HTTPS server)
    // java.lang.IllegalArgumentException: empty text (Use https://... URL to connect to HTTP server)
    val cause = e.getCause
    val s     = cause.toString
    if (s.startsWith("java.nio.channels.ClosedChannelException") ||
{'fraction_non_alphanumeric': 0.09778012684989429, 'fraction_numerical': 0.0, 'mean_word_length': 3.853846153846154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3398875', 'n_tokens_mistral': 520, 'n_tokens_neox': 513, 'n_words': 154}