在scala中使用Http客户端方法的协议寄存器

时间:2017-09-08 04:36:03

标签: scala ssl https httpclient

我想使用自定义ssl,所以我添加了一个带有以下文件的.jar(commons-httpclient-contrib.jar):

  

META-INF / MANIFEST.MF   org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory.class   org.apache.commons.httpclient.contrib.ssl.EasyX509TrustManager.class   org.apache.commons.httpclient.contrib.ssl.StrictSSLProtocolSocketFactory.class   org.apache.commons.httpclient.contrib.utils.HttpMethodCloner.class

Protocol.registerProtocol("https", new Protocol("https", new MySSLSocketFactory(), 443));
HttpClient httpclient = new HttpClient();
GetMethod httpget = new GetMethod("https://www.whatever.com/");
try {
  httpclient.executeMethod(httpget);
  System.out.println(httpget.getStatusLine());
} finally {
  httpget.releaseConnection();
}

我正在尝试将上面的代码转换为scala。但我没有成功,并且有编译错误。

0 个答案:

没有答案