| | |
| | | package com.ruoyi.common.utils.http; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.*; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import javax.servlet.ServletRequest; |
| | | import org.apache.commons.lang3.exception.ExceptionUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import static java.util.Collections.replaceAll; |
| | | |
| | | /** |
| | | * 通用http工具封装 |
| | |
| | | { |
| | | private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class); |
| | | |
| | | /** |
| | | * url编码 + 空格替换为 %20 %3A 替换为 : 主要是处理时间转换问题 |
| | | * @param str |
| | | * @param charset |
| | | * @return |
| | | * @throws UnsupportedEncodingException |
| | | */ |
| | | public static String UrlEncode(String str, String charset) throws UnsupportedEncodingException { |
| | | return URLEncoder.encode(str, charset).replaceAll("\\+", "%20").replaceAll("%3A", ":"); |
| | | } |
| | | |
| | | public static String getBodyString(ServletRequest request) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |