<commit_before>package eu.thog92.generator.api.http;

import eu.thog92.generator.api.BotGenerator;
import eu.thog92.generator.core.http.handler.ChannelHandler;
import eu.thog92.generator.util.MineTypeDatabase;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.http.*;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.SslProvider;
import io.netty.handler.stream.ChunkedWriteHandler;
import io.netty.util.CharsetUtil;

import javax.net.ssl.SSLException;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Pattern;

import static io.netty.handler.codec.http.HttpResponseStatus.FOUND;
import static io.netty.handler.codec.http.HttpResponseStatus.NOT_MODIFIED;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;

/**
 * Abstract layout for the http server
 * Created by Thog the 28/05/2016
 */
public class HttpServer
{

    public static final String HTTP_DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz";
    private static final String HTTP_DATE_GMT_TIMEZONE = "GMT";
    private static final int HTTP_CACHE_SECONDS = 60;
    private static final Pattern INSECURE_URI = Pattern.compile(".*[<>&\"].*");
    private final int port;
    private IRequestHandler defaultContext;
    private final Map<String, IRequestHandler> HANDLERS = new HashMap<>();
    private final ServerBootstrap bootstrap;
    private final EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    private final EventLoopGroup workerGroup = new NioEventLoopGroup();

    private HttpServer(int port, File sslDir)
    {
        this.port = port;
        HttpServer server = this;
        // Configure SSL.
        SslContext sslCtx = null;

        try
        {
            File sslCert = new File(sslDir, "server.cert");
            File sslPrivKey = new File(sslDir, "server.key");
            if (sslCert.exists() && sslPrivKey.exists())
                sslCtx = SslContextBuilder.forServer(sslCert, sslPrivKey).sslProvider(SslProvider.OPENSSL).build();
        } catch (SSLException e)
        {
            e.printStackTrace();
        }


        bootstrap = new ServerBootstrap();<commit_msg>Fix ClassNotFound exception caused by netty (fall back to JDK SSLProvider)<commit_after>package eu.thog92.generator.api.http;

import eu.thog92.generator.api.BotGenerator;
import eu.thog92.generator.core.http.handler.ChannelHandler;
import eu.thog92.generator.util.MineTypeDatabase;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.http.*;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.SslProvider;
import io.netty.handler.stream.ChunkedWriteHandler;
import io.netty.util.CharsetUtil;

import javax.net.ssl.SSLException;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Pattern;

import static io.netty.handler.codec.http.HttpResponseStatus.FOUND;
import static io.netty.handler.codec.http.HttpResponseStatus.NOT_MODIFIED;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;

/**
 * Abstract layout for the http server
 * Created by Thog the 28/05/2016
 */
public class HttpServer
{

    public static final String HTTP_DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz";
    private static final String HTTP_DATE_GMT_TIMEZONE = "GMT";
    private static final int HTTP_CACHE_SECONDS = 60;
    private static final Pattern INSECURE_URI = Pattern.compile(".*[<>&\"].*");
    private final int port;
    private IRequestHandler defaultContext;
    private final Map<String, IRequestHandler> HANDLERS = new HashMap<>();
    private final ServerBootstrap bootstrap;
    private final EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    private final EventLoopGroup workerGroup = new NioEventLoopGroup();

    private HttpServer(int port, File sslDir)
    {
        this.port = port;
        HttpServer server = this;
        // Configure SSL.
        SslContext sslCtx = null;

        try
        {
            File sslCert = new File(sslDir, "server.cert");
            File sslPrivKey = new File(sslDir, "server.key");
                sslCtx = SslContextBuilder.forServer(sslCert, sslPrivKey).sslProvider(SslProvider.JDK).build();
        } catch (SSLException e)
        {
            e.printStackTrace();
        }


        bootstrap = new ServerBootstrap();
{'fraction_non_alphanumeric': 0.10226835832372165, 'fraction_numerical': 0.008073817762399077, 'mean_word_length': 3.9411206077872745, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2493882', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1581, 'n_words': 352}