<commit_before>package unfiltered.netty.request

import unfiltered.response._
import unfiltered.request.{ Path => UFPath, POST, & }
import unfiltered.netty
import unfiltered.netty.{ Http => NHttp, ExceptionHandler }
import unfiltered.netty.cycle.ThreadPool

import dispatch.classic._
import dispatch.classic.mime.Mime._

import java.io.{ File => JFile }

import io.netty.buffer.Unpooled
import io.netty.channel.{ ChannelFutureListener, ChannelHandlerContext }

import org.specs.Specification

object NoChunkAggregatorSpec extends Specification
  with unfiltered.spec.netty.Served {

  trait ExpectedServerErrorResponse { self: ExceptionHandler =>
    def onException(ctx: ChannelHandlerContext, t: Throwable) {
      println("here!")
      val ch = ctx.channel
      if (ch.isOpen) try {
        println("expected exception occured: '%s'" format t.getMessage())
        val res = new DefaultFullHttpResponse(
          HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR,
          Unpooled.copiedBuffer(
            HttpResponseStatus.INTERNAL_SERVER_ERROR.toString.getBytes("utf-8")))
        ch.write(res).addListener(ChannelFutureListener.CLOSE)
      } catch {
        case _ => ch.close()
      }
    }
  }

  def setup = {
    _.handler(new netty.async.Plan with ExpectedServerErrorResponse {<commit_msg>fixup imports<commit_after>package unfiltered.netty.request

import unfiltered.response._
import unfiltered.request.{ Path => UFPath, POST, & }
import unfiltered.netty
import unfiltered.netty.{ Http => NHttp, ExceptionHandler }
import unfiltered.netty.cycle.ThreadPool

import dispatch.classic._
import dispatch.classic.mime.Mime._

import java.io.{ File => JFile }

import io.netty.buffer.Unpooled
import io.netty.channel.{ ChannelFutureListener, ChannelHandlerContext }
import io.netty.handler.codec.http.{ DefaultFullHttpResponse, HttpResponseStatus, HttpVersion }
import org.specs.Specification

object NoChunkAggregatorSpec extends Specification
  with unfiltered.spec.netty.Served {

  trait ExpectedServerErrorResponse { self: ExceptionHandler =>
    def onException(ctx: ChannelHandlerContext, t: Throwable) {
      println("here!")
      val ch = ctx.channel
      if (ch.isOpen) try {
        println("expected exception occured: '%s'" format t.getMessage())
        val res = new DefaultFullHttpResponse(
          HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR,
          Unpooled.copiedBuffer(
            HttpResponseStatus.INTERNAL_SERVER_ERROR.toString.getBytes("utf-8")))
        ch.write(res).addListener(ChannelFutureListener.CLOSE)
      } catch {
        case _ => ch.close()
      }
    }
  }

  def setup = {
    _.handler(new netty.async.Plan with ExpectedServerErrorResponse {
{'fraction_non_alphanumeric': 0.09675063891931361, 'fraction_numerical': 0.002190580503833516, 'mean_word_length': 3.892857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6610958', 'n_tokens_mistral': 822, 'n_tokens_neox': 801, 'n_words': 166}