[英]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();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.