<commit_before>/**
 * java utilites © darkslave.net
 * https://github.com/darkslave86/util
 */
 package net.darkslave.io;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.security.GeneralSecurityException;
import net.darkslave.crypto.SSLFactory;








/**
 * Загрузчик данных по http протоколу
 */
public class HttpLoader {
    private final HttpURLConnection connection;


    public static HttpLoader create(SSLFactory factory, String path) throws IOException, GeneralSecurityException {
        return create(factory.createConnection(path));
    }


    public static HttpLoader create(String path) throws IOException, GeneralSecurityException {
        return create(SSLFactory.DEFAULT_FACTORY.createConnection(path));
    }


    public static HttpLoader create(HttpURLConnection connection) {
        return new HttpLoader(connection);
    }


    private HttpLoader(HttpURLConnection connection) {
        this.connection = connection;
    }


    public void setRequestMethod(String method) throws ProtocolException {
        connection.setRequestMethod(method);
    }


    public void setConnectTimeout(int timeout) {
        connection.setConnectTimeout(timeout);
    }


    public void setReadTimeout(int timeout) {
        connection.setReadTimeout(timeout);
    }


    public void setRequestHeader(String key, String ... value) {
        int length = value.length;

        if (length == 0)
            throw new IllegalArgumentException("Header value can't be empty");

        connection.setRequestProperty(key, value[0]);

        if (length == 1)
            return;

        for (int i = 1; i < length; i++)
            connection.addRequestProperty(key, value[i]);

    }





}
<commit_msg>http loader<commit_after>/**
 * java utilites © darkslave.net
 * https://github.com/darkslave86/util
 */
 package net.darkslave.io;

import java.net.HttpURLConnection;
import java.net.ProtocolException;








/**
 * Загрузчик данных по http протоколу
 */
public class HttpLoader {
    private final HttpURLConnection connection;


    public HttpLoader(HttpURLConnection connection) {
        this.connection = connection;
    }


    public void setRequestMethod(String method) throws ProtocolException {
        connection.setRequestMethod(method);
    }


    public void setConnectTimeout(int timeout) {
        connection.setConnectTimeout(timeout);
    }


    public void setReadTimeout(int timeout) {
        connection.setReadTimeout(timeout);
    }


    public void setRequestHeader(String key, String ... value) {
        int length = value.length;

        if (length == 0)
            throw new IllegalArgumentException("Header value can't be empty");

        connection.setRequestProperty(key, value[0]);

        if (length == 1)
            return;

        for (int i = 1; i < length; i++)
            connection.addRequestProperty(key, value[i]);

    }





}

{'fraction_non_alphanumeric': 0.09155405405405405, 'fraction_numerical': 0.004054054054054054, 'mean_word_length': 2.9798387096774195, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2642797', 'n_tokens_mistral': 821, 'n_tokens_neox': 772, 'n_words': 197}