导航菜单

页面标题

页面副标题

Cashalo v2.25.0.0 - ConnectionFactory.java 源代码

正在查看: Cashalo v2.25.0.0 应用的 ConnectionFactory.java JAVA 源代码文件

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


package com.segment.analytics;

import com.fullstory.FS;
import com.google.common.net.HttpHeaders;
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/4.11.3";

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

    public HttpURLConnection upload(String str) throws IOException {
        HttpURLConnection openConnection = openConnection(String.format("https://%s/import", str));
        openConnection.setRequestProperty(HttpHeaders.CONTENT_ENCODING, "gzip");
        openConnection.setDoOutput(true);
        openConnection.setChunkedStreamingMode(0);
        return openConnection;
    }

    protected HttpURLConnection openConnection(String str) throws IOException {
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) FS.urlconnection_wrapInstance(new URL(str).openConnection());
            httpURLConnection.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS);
            httpURLConnection.setReadTimeout(DEFAULT_READ_TIMEOUT_MILLIS);
            httpURLConnection.setRequestProperty(HttpHeaders.CONTENT_TYPE, "application/json");
            httpURLConnection.setRequestProperty(HttpHeaders.USER_AGENT, USER_AGENT);
            httpURLConnection.setDoInput(true);
            return httpURLConnection;
        } catch (MalformedURLException e) {
            throw new IOException("Attempted to use malformed url: " + str, e);
        }
    }
}