<commit_before>package io.quarkus.vertx.http.runtime.devmode;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiFunction;

import org.jboss.logging.Logger;

import io.netty.buffer.Unpooled;
import io.quarkus.dev.console.DevConsoleManager;
import io.quarkus.dev.console.DevConsoleRequest;
import io.quarkus.dev.console.DevConsoleResponse;
import io.vertx.core.Handler;
import io.vertx.core.buffer.Buffer;
import io.vertx.ext.web.RoutingContext;

/**
 * This is a Handler running in the regular runtime Vert.x instance
 * and what it does is to take the Vert.x request coming from client (under /q/dev/)
 * and create the DevConsoleRequest that ends up being sent to the Netty Virtual Channel
 * which is eventually piped into the Netty event loop that powers the Dev Vert.x instance.
 */
public class DevConsoleFilter implements Handler<RoutingContext> {

    private static final Logger log = Logger.getLogger(DevConsoleFilter.class);

    @Override
    public void handle(RoutingContext event) {
        Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
        for (Map.Entry<String, String> entry : event.request().headers()) {
            headers.put(entry.getKey(), event.request().headers().getAll(entry.getKey()));
        }
        if (event.getBody() != null) {
            DevConsoleRequest request = new DevConsoleRequest(event.request().method().name(), event.request().path(), headers,
                    event.getBody().getBytes());
            setupFuture(event, request.getResponse());
            DevConsoleManager.sentRequest(request);
        } else if (event.request().isEnded()) {
            DevConsoleRequest request = new DevConsoleRequest(event.request().method().name(), event.request().path(), headers,
                    new byte[0]);
            setupFuture(event, request.getResponse());
            DevConsoleManager.sentRequest(request);
        } else {
            event.request().bodyHandler(new Handler<Buffer>() {
                @Override
                public void handle(Buffer body) {
                    DevConsoleRequest request = new DevConsoleRequest(event.request().method().name(), event.request().path(),
                            headers, body.getBytes());
                    setupFuture(event, request.getResponse());<commit_msg>DevConsoleFilter - query string should not be stripped away<commit_after>package io.quarkus.vertx.http.runtime.devmode;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiFunction;

import org.jboss.logging.Logger;

import io.netty.buffer.Unpooled;
import io.quarkus.dev.console.DevConsoleManager;
import io.quarkus.dev.console.DevConsoleRequest;
import io.quarkus.dev.console.DevConsoleResponse;
import io.vertx.core.Handler;
import io.vertx.core.buffer.Buffer;
import io.vertx.ext.web.RoutingContext;

/**
 * This is a Handler running in the regular runtime Vert.x instance
 * and what it does is to take the Vert.x request coming from client (under /q/dev/)
 * and create the DevConsoleRequest that ends up being sent to the Netty Virtual Channel
 * which is eventually piped into the Netty event loop that powers the Dev Vert.x instance.
 */
public class DevConsoleFilter implements Handler<RoutingContext> {

    private static final Logger log = Logger.getLogger(DevConsoleFilter.class);

    @Override
    public void handle(RoutingContext event) {
        Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
        for (Map.Entry<String, String> entry : event.request().headers()) {
            headers.put(entry.getKey(), event.request().headers().getAll(entry.getKey()));
        }
        if (event.getBody() != null) {
            DevConsoleRequest request = new DevConsoleRequest(event.request().method().name(), event.request().uri(), headers,
                    event.getBody().getBytes());
            setupFuture(event, request.getResponse());
            DevConsoleManager.sentRequest(request);
        } else if (event.request().isEnded()) {
            DevConsoleRequest request = new DevConsoleRequest(event.request().method().name(), event.request().uri(), headers,
                    new byte[0]);
            setupFuture(event, request.getResponse());
            DevConsoleManager.sentRequest(request);
        } else {
            event.request().bodyHandler(new Handler<Buffer>() {
                @Override
                public void handle(Buffer body) {
                    DevConsoleRequest request = new DevConsoleRequest(event.request().method().name(), event.request().uri(),
                            headers, body.getBytes());
                    setupFuture(event, request.getResponse());
{'fraction_non_alphanumeric': 0.11493104137517489, 'fraction_numerical': 0.0003997601439136518, 'mean_word_length': 3.219224283305228, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '5112449', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1296, 'n_words': 324}