<commit_before>package com.alecgorge.minecraft.jsonapi.packets.netty.router;

import net.minecraft.util.io.netty.buffer.Unpooled;
import net.minecraft.util.io.netty.handler.codec.http.DefaultFullHttpResponse;
import net.minecraft.util.io.netty.handler.codec.http.FullHttpResponse;
import net.minecraft.util.io.netty.handler.codec.http.HttpResponseStatus;
import net.minecraft.util.io.netty.handler.codec.http.HttpVersion;
import net.minecraft.util.io.netty.util.CharsetUtil;

import com.alecgorge.minecraft.jsonapi.JSONAPI;
import com.alecgorge.minecraft.jsonapi.packets.netty.APIv2Handler;

public class JSONAPIDefaultRoutes {
	JSONAPI	api;

	public JSONAPIDefaultRoutes(JSONAPI api) {
		this.api = api;

		RouteMatcher r = api.getRouter();
		r.get("/api/2/call", new Handler<FullHttpResponse, RoutedHttpRequest>() {
			@Override
			public FullHttpResponse handle(RoutedHttpRequest event) {
				APIv2Handler h = new APIv2Handler(event.request);

				return h.serve();
			}
		});

		r.get("/api/2/version", new Handler<FullHttpResponse, RoutedHttpRequest>() {
			@Override
			public FullHttpResponse handle(RoutedHttpRequest event) {
				APIv2Handler h = new APIv2Handler(event.request);

				return h.serve();
			}
		});

		r.get("/", new Handler<FullHttpResponse, RoutedHttpRequest>() {
			@Override
			public FullHttpResponse handle(RoutedHttpRequest event) {
				return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.copiedBuffer("This is a Minecraft server. HTTP on this port by JSONAPI. JSONAPI by <NAME>.", CharsetUtil.UTF_8));
			}
		});
	}
}
<commit_msg>fix router by using content-length<commit_after>package com.alecgorge.minecraft.jsonapi.packets.netty.router;

import net.minecraft.util.io.netty.buffer.ByteBuf;
import net.minecraft.util.io.netty.buffer.Unpooled;
import net.minecraft.util.io.netty.handler.codec.http.DefaultFullHttpResponse;
import net.minecraft.util.io.netty.handler.codec.http.FullHttpResponse;
import net.minecraft.util.io.netty.handler.codec.http.HttpResponseStatus;
import net.minecraft.util.io.netty.handler.codec.http.HttpVersion;
import net.minecraft.util.io.netty.util.CharsetUtil;

import com.alecgorge.minecraft.jsonapi.JSONAPI;
import com.alecgorge.minecraft.jsonapi.packets.netty.APIv2Handler;

public class JSONAPIDefaultRoutes {
	JSONAPI	api;

	public JSONAPIDefaultRoutes(JSONAPI api) {
		this.api = api;

		RouteMatcher r = api.getRouter();
		r.noMatch(new Handler<FullHttpResponse, RoutedHttpRequest>() {
			@Override
			public FullHttpResponse handle(RoutedHttpRequest event) {
				return buildResponse(HttpResponseStatus.OK, "text/plain", "Whatever you wanted wasn't found. This is a Minecraft server. HTTP on this port by JSONAPI. JSONAPI by <NAME>.\n");
			}
		});
		
		r.get("/api/2/call", new Handler<FullHttpResponse, RoutedHttpRequest>() {
			@Override
			public FullHttpResponse handle(RoutedHttpRequest event) {
				APIv2Handler h = new APIv2Handler(event.request);

				return h.serve();
			}
		});

		r.get("/api/2/version", new Handler<FullHttpResponse, RoutedHttpRequest>() {
			@Override
			public FullHttpResponse handle(RoutedHttpRequest event) {
				APIv2Handler h = new APIv2Handler(event.request);

				return h.serve();
			}
		});

		r.get("/", new Handler<FullHttpResponse, RoutedHttpRequest>() {
			@Override
			public FullHttpResponse handle(RoutedHttpRequest event) {
				return buildResponse(HttpResponseStatus.OK, "text/plain", "This is a Minecraft server. HTTP on this port by JSONAPI. JSONAPI by <NAME>.\n");
			}
		});
	}
	
	public static FullHttpResponse buildResponse(HttpResponseStatus resp, String type, String body) {
		ByteBuf buf = Unpooled.copiedBuffer(body, CharsetUtil.UTF_8);
		FullHttpResponse r = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, resp, buf);
		r.headers().set("Access-Control-Allow-Origin", "*");
		r.headers().set("Content-Length", buf.readableBytes());

		return r;
	}
}

{'fraction_non_alphanumeric': 0.11947919326014807, 'fraction_numerical': 0.0051059484299208575, 'mean_word_length': 4.909502262443439, 'pattern_counts': {'":': 0, '<': 13, '<?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': '5048557', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1274, 'n_words': 236}