无法通过代理隧道。代理返回“需要HTTP / 1.1 407代理身份验证”

时间:2018-10-05 12:57:25

标签: java https

我有下面的课程可以连接到HTTPS网址,

ID
DATAUID
MONTHVAL
VAL

然后在Unix服务器中使用以下命令执行该类

public class HKReader {

public static void main(String[] paramArrayOfString) {
    String str1 = paramArrayOfString[0];
    String str2 = paramArrayOfString[1];
    String str3 = paramArrayOfString[2];
    String str4 = paramArrayOfString[3];

    BufferedInputStream localBufferedInputStream = null;
    FileOutputStream localFileOutputStream = null;
    try {
        URL localURL = new URL(str1);
        URLConnection localURLConnection = localURL.openConnection();
        localURLConnection.setRequestProperty("Proxy-Authorization", "Basic" + new BASE64Encoder()
                .encode(new StringBuilder().append(str3).append(":").append(str4).toString().getBytes()));

        localBufferedInputStream = new BufferedInputStream(localURLConnection.getInputStream());
        localFileOutputStream = new FileOutputStream(new File(str2));
        int i;
        while ((i = localBufferedInputStream.read()) != -1) {
            localFileOutputStream.write(i);
        }
        return;
    } catch (MalformedURLException localMalformedURLException) {
        localMalformedURLException.printStackTrace();
        System.exit(-1);
    } catch (IOException localIOException3) {
        localIOException3.printStackTrace();
        System.exit(-1);
    } finally {
        try {
            if (localBufferedInputStream != null) {
                localBufferedInputStream.close();
            }
            if (localFileOutputStream != null) {
                localFileOutputStream.close();
            }
        } catch (IOException localIOException5) {
            localIOException5.printStackTrace();
            System.exit(-1);
        }
    }
}
}

我尝试了几次谷歌搜索,但是我遇到了错误。

$JAVA_HOME/bin/java -cp $LIB_DIR -Djdk.http.auth.tunneling.disabledSchemes="" -Dhttps.proxyHost=primary-proxy -Dhttps.proxyPort=8081 HKReader $url $target_file $proxyUser $proxyPassword

有人在我想念的地方可以帮我吗?

0 个答案:

没有答案