<commit_before>package net.trajano.ms.engine.internal.resteasy;

import java.io.InputStream;
import java.net.URI;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedMap;

import org.jboss.resteasy.core.SynchronousDispatcher;
import org.jboss.resteasy.plugins.server.BaseHttpRequest;
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
import org.jboss.resteasy.spi.HttpResponse;
import org.jboss.resteasy.spi.ResteasyAsynchronousContext;
import org.jboss.resteasy.spi.ResteasyUriInfo;

import io.vertx.core.http.HttpServerRequest;
import io.vertx.ext.web.RoutingContext;
import net.trajano.ms.engine.internal.Conversions;
import net.trajano.ms.engine.internal.VertxBlockingInputStream;

/**
 * For the most part the request is prebuilt and immutable. That way there is no
 * need for most of the setters.
 *
 * @author <NAME>
 */
public class VertxHttpRequest extends BaseHttpRequest {

    private final ResteasyAsynchronousContext asynchronousContext;

    private final Map<String, Object> attributes;

    private boolean forwarded;

    private final ResteasyHttpHeaders httpHeaders;

    private final VertxBlockingInputStream is;

    private final HttpServerRequest vertxRequest;

    public VertxHttpRequest(final RoutingContext context,
        final URI baseUri,
        final SynchronousDispatcher dispatcher) {

        super(new ResteasyUriInfo(context.normalisedPath(), context.request().query(), baseUri.toString()));

        vertxRequest = context.request();
        httpHeaders = new ResteasyHttpHeaders(Conversions.toMultivaluedStringMap(vertxRequest.headers()),
            Conversions.toCookies(context.cookies()));
        attributes = new HashMap<>();

        if (!vertxRequest.isEnded()) {
            is = new VertxBlockingInputStream();
            vertxRequest
                .handler(buffer -> is.populate(buffer))
                .endHandler(aVoid -> is.end());
        } else {
            is = null;
        }

        final HttpResponse response = new VertxHttpResponse(context);

        asynchronousContext = new VertxExecutionContext(context, dispatcher, this, response);
    }

    @Override
    public void forward(final String path) {

        throw new UnsupportedOperationException();
    }
<commit_msg>Used synchronous one since it yielded the same perf<commit_after>package net.trajano.ms.engine.internal.resteasy;

import java.io.InputStream;
import java.net.URI;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedMap;

import org.jboss.resteasy.core.SynchronousDispatcher;
import org.jboss.resteasy.core.SynchronousExecutionContext;
import org.jboss.resteasy.plugins.server.BaseHttpRequest;
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
import org.jboss.resteasy.spi.HttpResponse;
import org.jboss.resteasy.spi.ResteasyAsynchronousContext;
import org.jboss.resteasy.spi.ResteasyUriInfo;

import io.vertx.core.http.HttpServerRequest;
import io.vertx.ext.web.RoutingContext;
import net.trajano.ms.engine.internal.Conversions;
import net.trajano.ms.engine.internal.VertxBlockingInputStream;

/**
 * For the most part the request is prebuilt and immutable. That way there is no
 * need for most of the setters.
 *
 * @author <NAME>
 */
public class VertxHttpRequest extends BaseHttpRequest {

    private final ResteasyAsynchronousContext asynchronousContext;

    private final Map<String, Object> attributes;

    private boolean forwarded;

    private final ResteasyHttpHeaders httpHeaders;

    private final VertxBlockingInputStream is;

    private final HttpServerRequest vertxRequest;

    public VertxHttpRequest(final RoutingContext context,
        final URI baseUri,
        final SynchronousDispatcher dispatcher) {

        super(new ResteasyUriInfo(context.normalisedPath(), context.request().query(), baseUri.toString()));

        vertxRequest = context.request();
        httpHeaders = new ResteasyHttpHeaders(Conversions.toMultivaluedStringMap(vertxRequest.headers()),
            Conversions.toCookies(context.cookies()));
        attributes = new HashMap<>();

        if (!vertxRequest.isEnded()) {
            is = new VertxBlockingInputStream();
            vertxRequest
                .handler(buffer -> is.populate(buffer))
                .endHandler(aVoid -> is.end());
        } else {
            is = null;
        }

        final HttpResponse response = new VertxHttpResponse(context);

        asynchronousContext = new SynchronousExecutionContext(dispatcher, this, response);
    }

    @Override
    public void forward(final String path) {

        throw new UnsupportedOperationException();
    }

{'fraction_non_alphanumeric': 0.09104016477857879, 'fraction_numerical': 0.0, 'mean_word_length': 3.7701375245579567, 'pattern_counts': {'":': 0, '<': 9, '<?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': '986783', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1337, 'n_words': 301}