导航菜单

页面标题

页面副标题

Hopscotch v9.7.2 - ConnectionFactory.java 源代码

正在查看: Hopscotch v9.7.2 应用的 ConnectionFactory.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.segment.analytics;

import android.util.Base64;
import androidx.privacysandbox.ads.adservices.java.internal.a;
import com.payu.india.Payu.PayuConstants;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class ConnectionFactory {
    private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 15000;
    private static final int DEFAULT_READ_TIMEOUT_MILLIS = 20000;
    static final String USER_AGENT = "analytics-android/";

    private String authorizationHeader(String str) {
        return "Basic " + Base64.encodeToString((str + ":").getBytes(), 2);
    }

    public HttpURLConnection openConnection(String str) throws IOException {
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
            httpURLConnection.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS);
            httpURLConnection.setReadTimeout(DEFAULT_READ_TIMEOUT_MILLIS);
            httpURLConnection.setRequestProperty(PayuConstants.PAYU_CONTENT_TYPE, "application/json");
            httpURLConnection.setRequestProperty(com.payu.paymentparamhelper.PayuConstants.UPI_USER_AGENT, USER_AGENT);
            httpURLConnection.setDoInput(true);
            return httpURLConnection;
        } catch (MalformedURLException e) {
            throw new IOException(a.o("Attempted to use malformed url: ", str), e);
        }
    }

    public HttpURLConnection projectSettings(String str) throws IOException {
        return openConnection("https://cdn-settings.segment.com/v1/projects/" + str + "/settings");
    }

    public HttpURLConnection upload(String str, String str2) throws IOException {
        HttpURLConnection openConnection = openConnection("https://" + str);
        openConnection.setRequestProperty("Authorization", authorizationHeader(str2));
        openConnection.setRequestProperty("Content-Encoding", "gzip");
        openConnection.setDoOutput(true);
        openConnection.setChunkedStreamingMode(0);
        return openConnection;
    }
}