<commit_before><commit_msg>Added the DeproxyHttpRequest class.<commit_after>package org.rackspace.gdeproxy

import org.apache.http.client.methods.HttpEntityEnclosingRequestBase
import org.apache.http.client.utils.URIBuilder
import org.apache.http.entity.ByteArrayEntity
import org.apache.http.entity.StringEntity

class DeproxyHttpRequest extends HttpEntityEnclosingRequestBase {

    Request request;
    def uri;

    DeproxyHttpRequest(Request request, String scheme, String host, def port = null) {
        this.request = request;

        String url;
        def builder = new URIBuilder();
        builder.setScheme(scheme);
        builder.setHost(host);
        builder.setPath(request.path);
        if (port) {
            builder.setPort(port);
        }

        this.setURI(builder.build())

        request.headers.each { Header header ->
            this.addHeader(header.name, header.value);
        }

        if (request.body instanceof String) {
            this.setEntity(new StringEntity(request.body));
        } else if (request.body instanceof byte[]) {
            this.setEntity(new ByteArrayEntity(request.body));
        } else {
            throw new UnsupportedOperationException("Bad type of request.body");
        }
    }

    @Override
    String getMethod() {
        return request.method
    }
}
{'fraction_non_alphanumeric': 0.09534534534534535, 'fraction_numerical': 0.0, 'mean_word_length': 2.672176308539945, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7659175', 'n_tokens_mistral': 363, 'n_tokens_neox': 355, 'n_words': 75}