<commit_before>package hello;

import io.netty.buffer.MessageBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.DecoderResult;
import io.netty.handler.codec.http.Cookie;
import io.netty.handler.codec.http.CookieDecoder;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.handler.codec.http.ServerCookieEncoder;
import io.netty.util.CharsetUtil;

import java.util.Map;
import java.util.HashMap;
import java.util.Set;

import java.io.*;

import com.fasterxml.jackson.databind.*;

import static io.netty.handler.codec.http.HttpHeaders.Names.*;
import static io.netty.handler.codec.http.HttpHeaders.*;
import static io.netty.handler.codec.http.HttpResponseStatus.*;
import static io.netty.handler.codec.http.HttpVersion.*;

public class HelloServerHandler extends ChannelInboundMessageHandlerAdapter<Object> {

    private HttpRequest request;
    /** Buffer that stores the response content */
    private final StringBuilder buf = new StringBuilder();
    private static final ObjectMapper mapper = new ObjectMapper();

    private boolean flush;

    @Override
    public boolean beginMessageReceived(ChannelHandlerContext ctx) throws Exception {
        flush = false;
        return super.beginMessageReceived(ctx);
    }

    @Override
    public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
        MessageBuf<Object> out = ctx.nextOutboundMessageBuffer();
        if (msg instanceof HttpRequest) {
            HttpRequest request = this.request = (HttpRequest) msg;

            if (is100ContinueExpected(request)) {
                send100Continue(out);
            }
            
            Map<String, String> data = new HashMap<String, String>();
            data.put("message", "Hello, world");
            
            buf.setLength(0);
            try
            {
              buf.append(HelloServerHandler.mapper.writeValueAsString(data));
            }
            catch (IOException ex)
            {
              // do nothing
            }

            appendDecoderResult(buf, request);
        }

        if (msg instanceof HttpContent) {
            if (msg instanceof LastHttpContent) {
              LastHttpContent trailer = (LastHttpContent) msg;
              writeResponse(ctx, out, trailer);
            }
        }
    }

    private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
        DecoderResult result = o.getDecoderResult();
        if (result.isSuccess()) {<commit_msg>Netty plaintext test<commit_after>package hello;

import io.netty.buffer.MessageBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.codec.DecoderResult;
import io.netty.handler.codec.http.Cookie;
import io.netty.handler.codec.http.CookieDecoder;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.handler.codec.http.ServerCookieEncoder;
import io.netty.util.CharsetUtil;

import java.util.Map;
import java.util.HashMap;
import java.util.Set;

import java.io.*;

import com.fasterxml.jackson.databind.*;

import static io.netty.handler.codec.http.HttpHeaders.Names.*;
import static io.netty.handler.codec.http.HttpHeaders.*;
import static io.netty.handler.codec.http.HttpResponseStatus.*;
import static io.netty.handler.codec.http.HttpVersion.*;

public class HelloServerHandler extends ChannelInboundMessageHandlerAdapter<Object> {

    private HttpRequest request;
    /** Buffer that stores the response content */
    private final StringBuilder buf = new StringBuilder();
    private static final ObjectMapper mapper = new ObjectMapper();

    private boolean flush;

    @Override
    public boolean beginMessageReceived(ChannelHandlerContext ctx) throws Exception {
        flush = false;
        return super.beginMessageReceived(ctx);
    }

    @Override
    public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
        MessageBuf<Object> out = ctx.nextOutboundMessageBuffer();
        if (msg instanceof HttpRequest) {
            HttpRequest request = this.request = (HttpRequest) msg;

            if (is100ContinueExpected(request)) {
                send100Continue(out);
            }

            if("/plaintext".equals(request.getUri())) {
                buf.append("Hello, World!");
            } else {
                Map<String, String> data = new HashMap<String, String>();
                data.put("message", "Hello, world");
                
                buf.setLength(0);
                try
                {
                  buf.append(HelloServerHandler.mapper.writeValueAsString(data));
                }
                catch (IOException ex)
                {
                  // do nothing
                }
            }

            appendDecoderResult(buf, request);
        }

        if (msg instanceof HttpContent) {
            if (msg instanceof LastHttpContent) {
              LastHttpContent trailer = (LastHttpContent) msg;
              writeResponse(ctx, out, trailer);
            }
        }
    }

    private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
        DecoderResult result = o.getDecoderResult();
        if (result.isSuccess()) {
{'fraction_non_alphanumeric': 0.09690721649484536, 'fraction_numerical': 0.0022204599524187152, 'mean_word_length': 2.9437148217636024, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7653171', 'n_tokens_mistral': 1711, 'n_tokens_neox': 1655, 'n_words': 352}