| | |
| | | package com.doumee.core.utils; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.net.ssl.*; |
| | | import java.io.*; |
| | | import java.net.HttpURLConnection; |
| | |
| | | import java.security.SecureRandom; |
| | | import java.security.cert.CertificateException; |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | public class HttpsUtil { |
| | | |
| | | public static String get(String url,boolean ignoreSSL) { |
| | |
| | | try { |
| | | URL _url = new URL(url); |
| | | connection = (HttpURLConnection) _url.openConnection(); |
| | | System.out.println(connection.getContentLength()); |
| | | connection.setDoOutput(true); |
| | | connection.setRequestMethod("GET"); |
| | | return connection.getInputStream(); |
| | |
| | | } |
| | | return null; |
| | | } |
| | | public static Map<String,Object> connInputsteamReturnMap(String url, String method, String data, String contentType ){ |
| | | HttpURLConnection connection = null; |
| | | try { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | URL _url = new URL(url); |
| | | connection = (HttpURLConnection) _url.openConnection(); |
| | | connection.setDoOutput(true); |
| | | connection.setRequestMethod("GET"); |
| | | int size =connection.getContentLength(); |
| | | log.error("企业图片下载流实际大小:=========================="+size); |
| | | InputStream in =connection.getInputStream(); |
| | | if(in == null){ |
| | | log.error("企业图片下载流实际流为空:=========================="); |
| | | return null; |
| | | } |
| | | log.error("企业图片下载流大小:=========================="+in.available()); |
| | | map.put("data",in); |
| | | map.put("size",size); |
| | | return map; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | public static String connectionHttp(String url,String method,String data,String contentType ){ |
| | | HttpURLConnection connection = null; |
| | | try { |