| | |
| | | BufferedReader reader = null; |
| | | StringBuilder response = new StringBuilder(); |
| | | try { |
| | | log.info("请求地址 ->{}",httpUrl); |
| | | URL url = new URL(httpUrl); |
| | | connection = (HttpURLConnection) url.openConnection(); |
| | | connection.setRequestMethod("POST"); |
| | |
| | | } |
| | | connection.setDoOutput(true); |
| | | StringBuilder postData = new StringBuilder(); |
| | | log.info("入参 ->{}", JSONUtil.toJsonStr(maps)); |
| | | for (Map.Entry<String, Object> entry : maps.entrySet()) { |
| | | if (postData.length() > 0) { |
| | | postData.append("&"); |
| | |
| | | while ((line = reader.readLine()) != null) { |
| | | response.append(line); |
| | | } |
| | | log.info("返回 ->{}",response); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | |
| | | String boundary = "----WebKitFormBoundary" + UUID.randomUUID().toString().replaceAll("-", ""); |
| | | String CRLF = "\r\n"; |
| | | try { |
| | | log.info("请求地址 ->{}",httpUrl); |
| | | URL url = new URL(httpUrl); |
| | | connection = (HttpURLConnection) url.openConnection(); |
| | | connection.setRequestMethod("POST"); |
| | |
| | | connection.setRequestProperty("Authorization", authorization); |
| | | } |
| | | connection.setDoOutput(true); |
| | | log.info("入参 ->{}",maps); |
| | | outStream = new DataOutputStream(connection.getOutputStream()); |
| | | for (Map.Entry<String, Object> entry : maps.entrySet()) { |
| | | outStream.writeBytes("--" + boundary + CRLF); |
| | |
| | | while ((line = reader.readLine()) != null) { |
| | | response.append(line); |
| | | } |
| | | log.info("返回 ->{}",response); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |