确定 HttpPost 是否是 https 的实例
Determine if HttpPost is instance of https
如何判断连接是否为https实例?
HttpPost httpPost = new HttpPost(requestParameter.getHostUrl());
httpPost.setEntity(new StringEntity(requestParameter.getRequest()));
httpPost.setHeader(CONTENT_TYPE, requestParameter.getContentType());
因为我记得在 HttpURLConnection
你可以这样做:
URL url;
url = new URL(endpoint);
HttpURLConnection con;
try {
con = (HttpURLConnection) url.openConnection();
} catch (IOException e) {
}
// you can do something like:
if (con instanceof HttpsURLConnection)
看来你可以做到
HttpPost httpPost = new HttpPost(requestParameter.getHostUrl());
httpost.getURI().getScheme();
如何判断连接是否为https实例?
HttpPost httpPost = new HttpPost(requestParameter.getHostUrl());
httpPost.setEntity(new StringEntity(requestParameter.getRequest()));
httpPost.setHeader(CONTENT_TYPE, requestParameter.getContentType());
因为我记得在 HttpURLConnection
你可以这样做:
URL url;
url = new URL(endpoint);
HttpURLConnection con;
try {
con = (HttpURLConnection) url.openConnection();
} catch (IOException e) {
}
// you can do something like:
if (con instanceof HttpsURLConnection)
看来你可以做到
HttpPost httpPost = new HttpPost(requestParameter.getHostUrl());
httpost.getURI().getScheme();