<commit_before>package io.github.openunirest.http;

import io.github.openunirest.http.exceptions.UnirestException;
import org.apache.http.HttpEntity;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Objects;
import java.util.function.Function;

import static io.github.openunirest.http.utils.ResponseUtils.getCharsetfromResponse;
import static io.github.openunirest.http.utils.ResponseUtils.getRawBody;

public class BodyData<T>  {

    public static <T> BodyData<T> from(HttpEntity e, Function<BodyData<T>, T> transformer) {
        if(Objects.isNull(e)){
            return new BodyData<>();
        }
        BodyData d = new BodyData(e);
        d.transformBody(transformer);
        return d;
    }

    private final String charset;

    private final byte[] rawBytes;
    private final InputStream rawInput;
    private T transFormedBody;
    private RuntimeException parseEx;

    private BodyData() {
        charset = null;
        rawBytes = null;
        rawInput = null;
    }

    private BodyData(HttpEntity entity) {
        this.charset = getCharsetfromResponse(entity);
        this.rawBytes = getRawBody(entity);
        this.rawInput = new ByteArrayInputStream(rawBytes);
    }

    public String getCharset() {
        return charset;
    }

    public byte[] getRawBytes() {
        return rawBytes;
    }

    public InputStream getRawInput() {
        return rawInput;
    }
<commit_msg>no need to carry around the InputStream version of the body<commit_after>package io.github.openunirest.http;

import io.github.openunirest.http.exceptions.UnirestException;
import org.apache.http.HttpEntity;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Objects;
import java.util.function.Function;

import static io.github.openunirest.http.utils.ResponseUtils.getCharsetfromResponse;
import static io.github.openunirest.http.utils.ResponseUtils.getRawBody;

public class BodyData<T>  {

    public static <T> BodyData<T> from(HttpEntity e, Function<BodyData<T>, T> transformer) {
        if(Objects.isNull(e)){
            return new BodyData<>();
        }
        BodyData d = new BodyData(e);
        d.transformBody(transformer);
        return d;
    }

    private final String charset;

    private final byte[] rawBytes;
    private T transFormedBody;
    private RuntimeException parseEx;

    private BodyData() {
        charset = null;
        rawBytes = null;
    }

    private BodyData(HttpEntity entity) {
        this.charset = getCharsetfromResponse(entity);
        this.rawBytes = getRawBody(entity);
    }

    public String getCharset() {
        return charset;
    }

    public byte[] getRawBytes() {
        return rawBytes;
    }

    public InputStream getRawInput() {
        return new ByteArrayInputStream(rawBytes);
    }

{'fraction_non_alphanumeric': 0.09305604511808248, 'fraction_numerical': 0.0, 'mean_word_length': 3.089337175792507, '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': '7146559', 'n_tokens_mistral': 842, 'n_tokens_neox': 815, 'n_words': 190}