<commit_before>package com.payler.paylergateapi.lib.network;

import com.google.common.base.CaseFormat;
import com.payler.paylergateapi.lib.model.ConnectionException;
import com.payler.paylergateapi.lib.model.request.GateRequest;
import com.payler.paylergateapi.lib.model.response.GateError;
import com.payler.paylergateapi.lib.model.response.Response;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.exc.UnrecognizedPropertyException;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class RequestExecutor {

    private HttpClient mClient;
    private List<NameValuePair> mParams;
    private ObjectMapper mObjectMapper;

    public RequestExecutor() {
        mObjectMapper = new ObjectMapper();
        mObjectMapper.setPropertyNamingStrategy(new PropertyNamingStrategy
                .LowerCaseWithUnderscoresStrategy());
        mObjectMapper.setVisibilityChecker(mObjectMapper.getSerializationConfig()
                .getDefaultVisibilityChecker()
                .withFieldVisibility(JsonAutoDetect.Visibility.ANY)
                .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
                .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
                .withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
        mObjectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    }
    
    public Response executeRequest(String url, GateRequest request, Class <? extends Response> cls)
            throws ConnectionException {

        if (mClient == null) {
            mClient = HttpClientFactory.createPinnedHttpClient();
//            mClient = HttpClientFactory.createHttpClient();
        }

        HttpPost post = new HttpPost(url);
        post.setHeader("Content-type", "application/x-www-form-urlencoded");
        post.setHeader("Accept", "application/json");

        mParams = getParams(request);

        Response response = null;

        try {
            post.setEntity(new UrlEncodedFormEntity(mParams));

            HttpResponse httpResponse = mClient.execute(post);

            StatusLine statusLine = httpResponse.getStatusLine();
            HttpEntity entity = httpResponse.getEntity();

            if (entity == null) {
                throw new ClientProtocolException("Response contains no content");
            }<commit_msg>Revert "fix|Ignoring unknown fields bug SDK-147"<commit_after>package com.payler.paylergateapi.lib.network;

import com.google.common.base.CaseFormat;
import com.payler.paylergateapi.lib.model.ConnectionException;
import com.payler.paylergateapi.lib.model.request.GateRequest;
import com.payler.paylergateapi.lib.model.response.GateError;
import com.payler.paylergateapi.lib.model.response.Response;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.exc.UnrecognizedPropertyException;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class RequestExecutor {

    private HttpClient mClient;
    private List<NameValuePair> mParams;
    private ObjectMapper mObjectMapper;

    public RequestExecutor() {
        mObjectMapper = new ObjectMapper();
        mObjectMapper.setPropertyNamingStrategy(new PropertyNamingStrategy
                .LowerCaseWithUnderscoresStrategy());
        mObjectMapper.setVisibilityChecker(mObjectMapper.getSerializationConfig()
                .getDefaultVisibilityChecker()
                .withFieldVisibility(JsonAutoDetect.Visibility.ANY)
                .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
                .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
                .withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
        mObjectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);
    }
    
    public Response executeRequest(String url, GateRequest request, Class <? extends Response> cls)
            throws ConnectionException {

        if (mClient == null) {
            mClient = HttpClientFactory.createPinnedHttpClient();
//            mClient = HttpClientFactory.createHttpClient();
        }

        HttpPost post = new HttpPost(url);
        post.setHeader("Content-type", "application/x-www-form-urlencoded");
        post.setHeader("Accept", "application/json");

        mParams = getParams(request);

        Response response = null;

        try {
            post.setEntity(new UrlEncodedFormEntity(mParams));

            HttpResponse httpResponse = mClient.execute(post);

            StatusLine statusLine = httpResponse.getStatusLine();
            HttpEntity entity = httpResponse.getEntity();

            if (entity == null) {
                throw new ClientProtocolException("Response contains no content");
            }
{'fraction_non_alphanumeric': 0.09147869674185463, 'fraction_numerical': 0.00046992481203007516, 'mean_word_length': 3.804364183596689, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3405291', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1695, 'n_words': 283}