<commit_before>package com.playfab.internal;

import java.util.*;
import java.util.concurrent.*;
import java.net.*;
import java.io.*;
import com.google.gson.*;

import com.playfab.PlayFabSettings;
import com.playfab.PlayFabErrors.PlayFabError;
import com.playfab.PlayFabErrors.PlayFabErrorCode;
import com.playfab.PlayFabErrors.PlayFabJsonError;
import com.playfab.PlayFabErrors.PlayFabJsonSuccess;

public class PlayFabHTTP {
    private static Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();

    public static FutureTask<Object> doPost(final String url, final Object request, final String authType, final String authKey) {
        return new FutureTask<Object>(new Callable<Object>() {
            public Object call() throws Exception {
                return doPostPrivate(url, request, authType, authKey);
            }
        });
    }

    private static Object doPostPrivate(String url, Object request, String authType, String authKey) throws Exception {
        String bodyString = null;

        if(request == null) {
            bodyString = "{}";
        }
        else if (request instanceof String) {
            bodyString = (String)request;
        }
        else {
            bodyString = gson.toJson(request);
        }

        // System.out.println("Sending: " + bodyString);

        HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/json");
        if(authType != null) {
            con.setRequestProperty(authType, authKey);
        }
        con.setRequestProperty("X-PlayFabSDK", PlayFabSettings.SdkVersionString);
        con.setDoOutput(true);
        con.setDoInput(true);

        // Make the API-Call and get the normal response httpCode
        int httpCode = 503; // default to SERVICE_UNAVAILABLE
        try {
            OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream());
            writer.write(bodyString);
            writer.close();
            httpCode = con.getResponseCode();
        } catch(Exception e) {
            return GeneratePfError(httpCode, PlayFabErrorCode.ServiceUnavailable, "Failed to post to server: " + url, null);
        }

        // Get the response string
        String responseString = null;<commit_msg>Update PlayFabHTTP.java (#417)<commit_after>package com.playfab.internal;

import java.util.*;
import java.util.concurrent.*;
import java.net.*;
import java.io.*;
import com.google.gson.*;

import com.playfab.PlayFabSettings;
import com.playfab.PlayFabErrors.PlayFabError;
import com.playfab.PlayFabErrors.PlayFabErrorCode;
import com.playfab.PlayFabErrors.PlayFabJsonError;
import com.playfab.PlayFabErrors.PlayFabJsonSuccess;

public class PlayFabHTTP {
    private static final int timeoutInMilliseconds = 60000;
    private static Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();

    public static FutureTask<Object> doPost(final String url, final Object request, final String authType, final String authKey) {
        return new FutureTask<Object>(new Callable<Object>() {
            public Object call() throws Exception {
                return doPostPrivate(url, request, authType, authKey);
            }
        });
    }

    private static Object doPostPrivate(String url, Object request, String authType, String authKey) throws Exception {
        String bodyString = null;

        if(request == null) {
            bodyString = "{}";
        }
        else if (request instanceof String) {
            bodyString = (String)request;
        }
        else {
            bodyString = gson.toJson(request);
        }

        // System.out.println("Sending: " + bodyString);

        HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
        con.setConnectTimeout(timeoutInMilliseconds);
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/json");
        if(authType != null) {
            con.setRequestProperty(authType, authKey);
        }
        con.setRequestProperty("X-PlayFabSDK", PlayFabSettings.SdkVersionString);
        con.setDoOutput(true);
        con.setDoInput(true);

        // Make the API-Call and get the normal response httpCode
        int httpCode = 503; // default to SERVICE_UNAVAILABLE
        try {
            OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream());
            writer.write(bodyString);
            writer.close();
            httpCode = con.getResponseCode();
        } catch(Exception e) {
            return GeneratePfError(httpCode, PlayFabErrorCode.ServiceUnavailable, "Failed to post to server: " + url, null);
        }

        // Get the response string
        String responseString = null;
{'fraction_non_alphanumeric': 0.10393895648587338, 'fraction_numerical': 0.0028871932357187047, 'mean_word_length': 2.803921568627451, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6081067', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1287, 'n_words': 308}