Commit 7815ba36 authored by Quxl's avatar Quxl

x

parent 9bad7bc7
...@@ -11,10 +11,15 @@ import java.util.Map; ...@@ -11,10 +11,15 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
public class HttpUtil { public class HttpUtil {
static Log logger = LogFactory.getLog(HttpUtil.class);
public static String get(String requestUrl, Map<String, String> headers) { public static String get(String requestUrl, Map<String, String> headers) {
HttpURLConnection connection = null; HttpURLConnection connection = null;
try { try {
...@@ -76,6 +81,9 @@ public class HttpUtil { ...@@ -76,6 +81,9 @@ public class HttpUtil {
} }
public static String post(String requestUrl, Map<String, Object> parameters, Map<String, String> headers) { public static String post(String requestUrl, Map<String, Object> parameters, Map<String, String> headers) {
logger.debug(requestUrl);
logger.debug(JSON.toJSONString(parameters));
logger.debug(JSON.toJSONString(headers));
HttpURLConnection connection = null; HttpURLConnection connection = null;
try { try {
String requestBody = toQueryString(parameters); String requestBody = toQueryString(parameters);
...@@ -91,7 +99,9 @@ public class HttpUtil { ...@@ -91,7 +99,9 @@ public class HttpUtil {
} }
} }
connection.connect(); connection.connect();
return responseBody(connection); String result = responseBody(connection);
logger.debug(result);
return result;
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
...@@ -101,6 +111,9 @@ public class HttpUtil { ...@@ -101,6 +111,9 @@ public class HttpUtil {
public static String postRaw(String requestUrl, Map<String, Object> parameters, Map<String, String> headers) { public static String postRaw(String requestUrl, Map<String, Object> parameters, Map<String, String> headers) {
logger.debug(requestUrl);
logger.debug(JSON.toJSONString(parameters));
logger.debug(JSON.toJSONString(headers));
HttpURLConnection connection = null; HttpURLConnection connection = null;
OutputStream os = null; OutputStream os = null;
try { try {
...@@ -120,7 +133,9 @@ public class HttpUtil { ...@@ -120,7 +133,9 @@ public class HttpUtil {
String rawData = JSON.toJSONString(parameters); String rawData = JSON.toJSONString(parameters);
os.write(rawData.getBytes()); os.write(rawData.getBytes());
os.flush(); os.flush();
return responseBody(connection); String result = responseBody(connection);
logger.debug(result);
return result;
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
</root> </root>
</springProfile> </springProfile>
<logger name="com.egolm.sso" level="DEBUG" />
<logger name="com.egolm.sso.config.ExceptionAspect" level="ERROR"> <logger name="com.egolm.sso.config.ExceptionAspect" level="ERROR">
<appender-ref ref="errorAppender" /> <appender-ref ref="errorAppender" />
</logger> </logger>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment