<commit_before>package com.apitrary.api.client;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;

import javax.ws.rs.core.MediaType;

import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;

import com.apitrary.api.client.exception.CommunicationErrorException;
import com.apitrary.api.client.exception.SerializationException;
import com.apitrary.api.client.support.AbstractApitraryClient;
import com.apitrary.api.client.util.RequestUtil;
import com.apitrary.api.request.Request;
import com.apitrary.api.response.Response;

public class ApitraryClient extends AbstractApitraryClient {

	private ApitraryApi api;

	private ApitraryClient(ApitraryApi api) {
		this.api = api;
	}

	public static ApitraryClient connectTo(ApitraryApi api) {
		return new ApitraryClient(api);
	}

	public <T> T send(Request<T> request) {

		if (request == null) {
			throw new CommunicationErrorException("Request cannot be null.");
		}
		RequestUtil.validate(request);

		T response = (T) dispatchByMethod(request);
		return response;
	}

	private HashMap<String, String> prepareHeader() {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(apiAuthHeaderKey, api.getApiKey());
		return map;
	}

	protected <T> String inquireVHost() {
		return protocol + api.getApiId() + "." + apitraryUrl;
	}

	@Override
	protected <T> Response<T> deserialize(String response, Request<T> request) {
		Response<T> target = RequestUtil.getInstanceOfParameterizedType(request);

		try {
			return resultSerializer.fromJSON(response, target);
		} catch (SerializationException jse) {
			return target;
		}
	}

	@Override
	protected <T> Response<T> deserialize(InputStream inputStream, Request<T> request) {
		String content = null;
		try {
			content = IOUtils.readStringFromStream(inputStream);
		} catch (IOException e) {
			throw new SerializationException(e);
		}

		return deserialize(content, request);
		
	}

	@Override
	protected WebClient instantiateWebClient() {
		WebClient webClient = WebClient.create(inquireVHost());
		webClient = webClient.accept(MediaType.APPLICATION_JSON);
		webClient = webClient.header("apiAuthHeaderKey", api.getApiKey());
		webClient = webClient.header("Content-Type", "application/json");
		
		HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
		TLSClientParameters params = conduit.getTlsClientParameters();
		if (params == null) {
			params = new TLSClientParameters();
			conduit.setTlsClientParameters(params);
		}
		params.setDisableCNCheck(true);

		HTTPClientPolicy policy = new HTTPClientPolicy();
		policy.setConnectionTimeout(600000);
		policy.setReceiveTimeout(600000);
		policy.setAllowChunking(false);
		conduit.setClient(policy);
		
		return webClient;
	}
}<commit_msg>Partial<commit_after>package com.apitrary.api.client;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;

import javax.ws.rs.core.MediaType;

import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;

import com.apitrary.api.client.exception.CommunicationErrorException;
import com.apitrary.api.client.exception.SerializationException;
import com.apitrary.api.client.support.AbstractApitraryClient;
import com.apitrary.api.client.util.RequestUtil;
import com.apitrary.api.request.Request;
import com.apitrary.api.response.Response;

public class ApitraryClient extends AbstractApitraryClient {

	private ApitraryApi api;

	private ApitraryClient(ApitraryApi api) {
		this.api = api;
	}

	public static ApitraryClient connectTo(ApitraryApi api) {
		return new ApitraryClient(api);
	}

	public <T> T send(Request<T> request) {

		if (request == null) {
			throw new CommunicationErrorException("Request cannot be null.");
		}
		RequestUtil.validate(request);

		T response = (T) dispatchByMethod(request);
		return response;
	}

	private HashMap<String, String> prepareHeader() {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(apiAuthHeaderKey, api.getApiKey());
		return map;
	}

	protected <T> String inquireVHost() {
		return protocol + api.getApiId() + "." + apitraryUrl;
	}

	@Override
	protected <T> Response<T> deserialize(String response, Request<T> request) {
		Response<T> target = RequestUtil.getInstanceOfParameterizedType(request);

		try {
			return resultSerializer.fromJSON(response, target);
		} catch (SerializationException jse) {
			return target;
		}
	}

	@Override
	protected <T> Response<T> deserialize(InputStream inputStream, Request<T> request) {
		String content = null;
		try {
			content = IOUtils.readStringFromStream(inputStream);
		} catch (IOException e) {
			throw new SerializationException(e);
		}

		return deserialize(content, request);
		
	}

	@Override
	protected WebClient instantiateWebClient() {
		WebClient webClient = WebClient.create(inquireVHost());
		webClient = webClient.accept(MediaType.APPLICATION_JSON);
		webClient = webClient.header(apiAuthHeaderKey, api.getApiKey());
		webClient = webClient.header("Content-Type", "application/json");
		
		HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
		TLSClientParameters params = conduit.getTlsClientParameters();
		if (params == null) {
			params = new TLSClientParameters();
			conduit.setTlsClientParameters(params);
		}
		params.setDisableCNCheck(true);

		HTTPClientPolicy policy = new HTTPClientPolicy();
		policy.setConnectionTimeout(600000);
		policy.setReceiveTimeout(600000);
		policy.setAllowChunking(false);
		conduit.setClient(policy);
		
		return webClient;
	}
}
{'fraction_non_alphanumeric': 0.11133603238866396, 'fraction_numerical': 0.004048582995951417, 'mean_word_length': 5.451577801958651, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '421481', 'n_tokens_mistral': 1993, 'n_tokens_neox': 1831, 'n_words': 358}