日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

代理配置

更新時間:

本文為您介紹V2.0 Java SDK對于代理的配置方式。

代理配置方式

說明

代理配置優先級:RuntimeOption配置>Client配置,優先級依次降低。

  • 支持通過運行時參數(RuntimeOptions)配置當前請求的代理。

    import com.aliyun.ecs20140526.Client;
    import com.aliyun.ecs20140526.models.DescribeRegionsRequest;
    import com.aliyun.teaopenapi.models.Config;
    import com.aliyun.teautil.models.RuntimeOptions;
    
    public class Sample {
        public static void main(String[] args) throws Exception {
            Config config = new Config();
            // 從環境變量獲取RAM用戶的AccessKey ID
            config.setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"));
            // 從環境變量獲取RAM用戶的AccessKey Secret
            config.setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
            // 地域ID
            config.setRegionId("<regionId>");
            Client client = new Client(config);
    
            // 運行時參數設置,僅對使用了該運行時參數實例的請求有效
            RuntimeOptions runtimeOptions = new RuntimeOptions();
            runtimeOptions.httpProxy = "http://127.0.0.1:9898";
            runtimeOptions.httpsProxy = "http://user:password@127.0.0.1:8989";
            runtimeOptions.noProxy = "127.0.0.1,localhost";
    
            DescribeRegionsRequest describeRegionsRequest = new DescribeRegionsRequest();
    
            client.describeRegionsWithOptions(describeRegionsRequest, runtimeOptions);
        }
    }
  • 支持通過Config在初始化Client階段設置請求的代理。

    import com.aliyun.ecs20140526.Client;
    import com.aliyun.ecs20140526.models.DescribeRegionsRequest;
    import com.aliyun.teaopenapi.models.Config;
    import com.aliyun.teautil.models.RuntimeOptions;
    
    public class Sample {
        public static void main(String[] args) throws Exception {
            Config config = new Config();
            // 從環境變量獲取RAM用戶的AccessKey ID
            config.setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"));
            // 從環境變量獲取RAM用戶的AccessKey Secret
            config.setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
            // 地域ID
            config.setRegionId("<regionId>");
            // Client代理參數設置
            config.setHttpProxy("http://127.0.0.1:9898");
            config.setHttpsProxy("http://user:password@127.0.0.1:8989");
            config.setNoProxy("127.0.0.1,localhost");
            Client client = new Client(config);
    
            RuntimeOptions runtimeOptions = new RuntimeOptions();
            DescribeRegionsRequest describeRegionsRequest = new DescribeRegionsRequest();
    
            client.describeRegionsWithOptions(describeRegionsRequest, runtimeOptions);
        }
    }